If I run script with GUI ,everything is fine.
Trying to run in console with FreeCAD 0.17, Libs: 0.17R13541 (Git),I got "Unknown C++ exception" error.
Code: Select all
File "E:/workspace/testing/FreeCad/importFace.py", line 24, in export_step
Draft.makeSketch(activeDoc.getObject(name), addTo=baseSketch)
File "E:\workspace\testing\FreeCAD-0.17.13541.9948ee4-WIN-x64-portable\Mod\Draft\Draft.py", line 2834, in makeSketch
nobj.addGeometry(DraftGeomUtils.orientEdge(newedge,norm,make_arc=True))
File "E:\workspace\testing\FreeCAD-0.17.13541.9948ee4-WIN-x64-portable\Mod\Draft\DraftGeomUtils.py", line 572, in orientEdge
edge.rotate(base, axis, angle)
Base.FreeCADError: Unknown C++ exception
Code: Select all
if angle:
if axis == Vector (0.0, 0.0, 0.0):
axis = Vector (0.0, 0.0, 1.0)
edge.rotate(base, axis, angle)
If I run script with 0.18 version, there is no Unknown C++ exception but still exception.
Thank you for your time.
Code: Select all
import sys
import os
thisDir= r"E:\workspace\testing"
sys.path.append(os.path.join(thisDir, "FreeCAD-0.17.13541.9948ee4-WIN-x64-portable", "bin"))
import FreeCAD
import Import
import Draft
import Sketcher
import Part
def export_step(stepFilePath, exportStepFilePath):
App.newDocument("doc")
Import.insert(stepFilePath, "doc")
activeDoc=FreeCAD.ActiveDocument
names = [obj.Name for obj in activeDoc.Objects]
baseSketch=activeDoc.addObject('Sketcher::SketchObject', 'SketchCombine')
for name in names:
Draft.makeSketch(activeDoc.getObject(name), addTo=baseSketch)
activeDoc.recompute()
activeDoc.addObject("Part::Face", "Face").Sources = (baseSketch,)
activeDoc.recompute()
__objs__ = []
__objs__.append(activeDoc.getObject("Face"))
Import.export(__objs__, exportStepFilePath)
# del __objs__
# FreeCAD.closeDocument(activeDoc.Name)
print("Done. File has been export to {}".format(exportStepFilePath))
if __name__=='__main__':
stepFilePath = r"E:/workspace/testing/test.step"
exportStepFilePath = stepFilePath[:-5] + '-face.step'
export_step(stepFilePath, exportStepFilePath)