Code: Select all
Mesh.open(INPUT)
App.setActiveDocument("Unnamed")
App.ActiveDocument=App.getDocument("Unnamed")
FreeCAD.getDocument("Unnamed").addObject("Part::Feature","bracket001")
__shape__=Part.Shape()
__shape__.makeShapeFromMesh(FreeCAD.getDocument("Unnamed").getObject("bracket").Mesh.Topology,0.100000)
FreeCAD.getDocument("Unnamed").getObject("bracket001").Shape=__shape__
FreeCAD.getDocument("Unnamed").getObject("bracket001").purgeTouched()
del __shape__
App.ActiveDocument.addObject('Part::Feature','bracket001').Shape=App.ActiveDocument.bracket001.Shape.removeSplitter()
App.ActiveDocument.ActiveObject.Label=App.ActiveDocument.bracket001.Label
App.ActiveDocument.recompute()
__objs__=[]
__objs__.append(FreeCAD.getDocument("Unnamed").getObject("bracket001001"))
Part.export(__objs__,u"output.step")
del __objs__
I tried to make the code more generic (to account for different files names and different Mesh numbers). Following is what I came up with
Code: Select all
Mesh.open(INPUT)
App.setActiveDocument("Unnamed")
App.ActiveDocument=App.getDocument("Unnamed")
objects = FreeCAD.getDocument("Unnamed").Objects
FreeCAD.getDocument("Unnamed").addObject("Part::Feature","Feature_1")
__objs__=[]
for ob in objects:
mesh = ob.Name
print("MESH NAME:" + mesh)
__shape__=Part.Shape()
__shape__.makeShapeFromMesh(FreeCAD.getDocument("Unnamed").getObject("mesh").Mesh.Topology,0.100000)
FreeCAD.getDocument("Unnamed").getObject("Feature_1").Shape=__shape__
FreeCAD.getDocument("Unnamed").getObject("Feature_1").purgeTouched()
del __shape__
App.ActiveDocument.addObject('Part::Feature','Feature_1').Shape=App.ActiveDocument.Feature_1.Shape.removeSplitter()
App.ActiveDocument.ActiveObject.Label=App.ActiveDocument.Feature_1.Label
App.ActiveDocument.recompute()
# __objs__=[]
__objs__.append(FreeCAD.getDocument("Unnamed").getObject("Feature_2"))
Part.export(__objs__,u"output.step")
del __objs__