Need help about "projectToSVG"

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
zardrix
Posts: 1
Joined: Sun Nov 17, 2013 5:59 pm

Need help about "projectToSVG"

Post by zardrix »

Hello :D ,

I have some questions about the svg output of a view from FreeCAD.

Code: Select all

resultSVG = Drawing.projectToSVG(Shape,App.Vector(1,1,1))
the result is consisting of multiple single path elements, like:

Code: Select all

...
<path id= "1" d=" M 200 0 L 200 100 " />
<path id= "2" d=" M 200 100 L 100 100 " />
<path id= "3" d=" M 100 0 L 100 100 " />
<path id= "3" d=" M 100 0 L 200 0 " />
...
Is it possible to extract the view with the form of all the edges of a face in a single closed path? :?:
e.g.

Code: Select all

...
<path id= "1" d="M 200 0 L 200 100 L 100 100 L 100 0 L 200 0 z" />
<path id= "2" d="M ...L...L...L... z" />
...
If not, could someone please give me some advice how to easily convert to this form with python? :idea:

Thanks a lot!
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Need help about "projectToSVG"

Post by wmayer »

What do you mean with "restore the view"? Restoring the original 3d object from before the projection? No, this is not possible.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Need help about "projectToSVG"

Post by yorik »

The default projection algorithm used by FreeCAD to project shapes to 2D SVG objects is part of Opencascade, and it indeed projects all edges as separated lines. This is, I suppose, because many times it needs to cut the edges that are partly hidden... Anyway, there is no way we can currently recreate paths from it.

But in the Draft workbench, in the Draft->Drawing tool I made an alternative algorithm that does project faces as paths. This allows for example to give them a fill. But that tool will project faces individually, without any sorting. So it will only work well for flat objects.

In the Arch module, I am also experimenting with a new system to project 3D objects as a series of closed paths, with faces sorting. But it is still pretty experimental and doesn't always work well...
Post Reply