Export drawing sheets of FreeCAD into PDF and SVG format from Python console – Done

Finally, I found the answer that how to save the drawing sheets in FreeCAD from Python console. In FreeCAD, whenever we created a new drawing sheet its get stored as temporary file in our system. The below code is used to find the location of the drawing from Python console:

import os
import subprocess

obj = App.ActiveDocument.getObject("Page")
page = getattr(obj, 'PageResult')

The page variable stored the location of the drawing sheet in SVG format.

Converting SVG format to PDF format by using Inkscape:

import os
import subprocess

obj = App.ActiveDocument.getObject("Page")

# Path to Inkscape executable
inkscape_path = "/usr/bin/inkscape"

# Exported PDF file location
file_location = os.path.expanduser("~" + os.sep + obj.Label + ".pdf")

page = getattr(obj, 'PageResult')
call_inkscape = [inkscape_path, "-f", obj.PageResult, "-A", file_location]
subprocess.call(call_inkscape)
FollowFollow on FacebookFollow on Google+Email this to someone

One thought on “Export drawing sheets of FreeCAD into PDF and SVG format from Python console – Done

  1. Good one.

    Perhaps “Exporting FreeCAD drawing sheets into PDF and SVG from Python console” makes better heading. Isn’t?

Leave a Reply

Your email address will not be published. Required fields are marked *