1) Do you have sample image or dxf file?
2) I'm think it can be made from Part.makeFace, I will test.
1) Do you have sample image or dxf file?
Just need to fill two rectangles with two different solid color.
Code: Select all
from FreeCAD import Base
import Part
V1=Base.Vector(0,0,0)
V2=Base.Vector(300,0,0)
V3=Base.Vector(300,150,0)
V4=Base.Vector(0,150,0)
L1=Part.LineSegment(V1,V2)
L2=Part.LineSegment(V2,V3)
L3=Part.LineSegment(V3,V4)
L4=Part.LineSegment(V4,V1)
S=Part.Shape([L1,L2,L3,L4])
W=Part.Wire(S.Edges)
F=Part.Face(W)
#F.DiffuseColor=[(1.,1.,0.),(0.,1.,1.),(1.,0.,1.),(1.,0.,0.),(0.,1.,0.),(0.,0.,1.)]
Part.show(F)
I gave a quick look at the code as I was really curious. Looks like you are drawing every hatch line as an Edge. This doesn't look the good approach to me: you will have a lot of unuseful Part Shapes in your document, making the file too heavy too quick.
And the same with dashed lines: why dont use obj.ViewObject.DrawStyle="Dashed"? (this field is something I didnt' really got involved, so perhaps there are limitations when you want to have multiple DrawStyle for just one object).2) The dashed line assign by array [line , blank] or [line1 , blank1 , line2 , blank2] , like stroke-dasharray in SVG.
I cannot compile WB with C++. Draft WB made by C++,that difficult for me. Now,I try to read and understand the discussion.carlopav wrote: ↑Tue Jun 30, 2020 7:18 am I gave a quick look at the code as I was really curious. Looks like you are drawing every hatch line as an Edge. This doesn't look the good approach to me: you will have a lot of unuseful Part Shapes in your document, making the file too heavy too quick.
Draft workbench objects have the possibility to display an SVG hatching. The problem is that it seems to be broken in 0.19. Perhaps trying to fix this can also give some benefit to your objects would you join the efforts?
..
And the same with dashed lines: why dont use obj.ViewObject.DrawStyle="Dashed"? (this field is something I didnt' really got involved, so perhaps there are limitations when you want to have multiple DrawStyle for just one object).
Probably if you are going to build your own objects and therefor your workbench it worths experimenting a bit also with pivy library (from pivy import coin): it could help you to setup your viewprovider with all the visual style you need.
Edit: the link with the big discussion I linked shows that the field you are experimenting is something that users really need, so I'm happy to see you into it! So go on, and scratch the itch, but also consider if something that you need can be implemented at Draft workbech level, so the whole freecad project can benefit of it.
Draft workbench is pure Python (no c++ at all) check it out! https://github.com/FreeCAD/FreeCAD/tree ... /Mod/Draft
Let's say there is space to improve!P.S. and I have some problem about my english.