export techdraw to svg

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
matteofilippetto
Posts: 10
Joined: Wed Jun 22, 2022 4:22 pm

export techdraw to svg

Post by matteofilippetto »

Hi all,

using Freecad 0.19 on mac osx. I have some troubles exporting a TechDraw::DrawPage to SVG format . Exporting the same object to DXF format works fine.

This is the code used to export to DXF and works fine

Code: Select all

expfile = "filedxf.DXF"
objexp = 'Pagina1'
obj = self._fcdoc.getObject(objexp)
TechDraw.writeDXFPage(obj, expfile)
This is the code used to export to SVG

Code: Select all

expfile = "filesvg.SVG"
objexp = 'Pagina1'
objlist = []
objlist.append(self._fcdoc.getObject(objexp))
importSVG.export(objlist, expfile)
that return error "AttributeError: 'NoneType' object has no attribute 'RootNode'"

Could someone help me understand what I'm doing wrong?

Attached the FCStd file . TechDraw::DrawPage object has name 'Pagina1' .

Thank you for your help
Regards
Attachments
test9.FCStd
(76.11 KiB) Downloaded 7 times
User avatar
wandererfan
Veteran
Posts: 6309
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: export techdraw to svg

Post by wandererfan »

matteofilippetto wrote: Wed Jun 22, 2022 7:50 pm using Freecad 0.19 on mac osx. I have some troubles exporting a TechDraw::DrawPage to SVG format . Exporting the same object to DXF format works fine.
I would use "TechDrawGui.exportPageAsSvg(DrawPageObject, FilePath)". This uses the same code as TechDraw_ExportPageSVG.
matteofilippetto
Posts: 10
Joined: Wed Jun 22, 2022 4:22 pm

Re: export techdraw to svg

Post by matteofilippetto »

Sorry but I forgot to specify that I'm using python scripting headless so without Gui and therefore I can't use any Gui methods

Regards
User avatar
wandererfan
Veteran
Posts: 6309
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: export techdraw to svg

Post by wandererfan »

matteofilippetto wrote: Wed Jun 22, 2022 8:32 pm Sorry but I forgot to specify that I'm using python scripting headless so without Gui and therefore I can't use any Gui methods
Then I don't think this is possible. The page image is only created on the Gui side. The Dxf export is done on the App side and only uses the geometry of the objects (which is why appearances attributes aren't included in TD Dxf exports).
Post Reply