kbwbe / A2plus

Another assembly workbench for FreeCAD, following and extending Hamish's Assembly 2 workbench
GNU Lesser General Public License v2.1
168 stars 69 forks source link

a2plus assembly exporting to stl of parts in individual files #626

Open missionsave opened 5 months ago

missionsave commented 5 months ago

I got this code working, but the stl files looses the position and rotation of the parts in the assembly a2plus, how to fix that?

`

import FreeCAD

import Mesh

doc = App.ActiveDocument

export_directory = "./"

for obj in doc.Objects: 
  if obj.isDerivedFrom("Part::Feature"): 
    global_transform = obj.Placement

    temp_obj = doc.addObject("Part::Feature", obj.Label + "_temp")
    temp_obj.Shape = obj.Shape

    temp_obj.Placement = global_transform

    stl_path = export_directory + obj.Label + ".stl"
    Mesh.export([temp_obj], stl_path)

    doc.removeObject(temp_obj.Name)`

Thanks

missionsave commented 5 months ago

Well, tested in the latest development build of Freecad and it saves the positions allright with the assembly, but the front view appears as top view in the stl files, they're all rotated but consistent.