I am using FreeCAD 0.18.3 with python scripting to batch producing three-view line drawings (front, right, and top view) for 10,000 STEP files. The script runs well. However, when the FreeCAD python console runs for long time, like several hours, the FreeCAD will crash and quit suddenly. I have no idea since python does not require release memory manually, and I am not sure where I might make a mistake. For your convenience, I pose the core part of my code as follows:
Code: Select all
import FreeCAD, Part, Draft, Drawing, DrawingGui, TechDraw, TechDrawGui
def export_three_view(x,filepath):
a=FreeCAD.getDocument("Unnamed").getObject(x)
TechDrawGui.exportPageAsSvg(a,filepath)
del a
for file in dirs:
ImportGui.open(file)
App.setActiveDocument("Unnamed")
App.ActiveDocument=App.getDocument("Unnamed")
Gui.ActiveDocument=Gui.getDocument("Unnamed")
Gui.SendMsgToActiveView("ViewFit")
Gui.Selection.clearSelection()
#compound all the parts to a whole object...
App.activeDocument().addObject('TechDraw::DrawPage','Page')
App.activeDocument().addObject('TechDraw::DrawSVGTemplate','Template')
App.activeDocument().Template.Template = "my/path/A3_Landscape_blank.svg"
App.activeDocument().Page.Template = App.activeDocument().Template
App.activeDocument().addObject('TechDraw::DrawProjGroup','ProjGroup')
App.activeDocument().Page.addView(App.activeDocument().ProjGroup)
#Front
#TODO: set the front perspective...
export_three_view("Page", MY_PATH)
break
Thanks so much if you have any suggestions!