Skip to content

Instantly share code, notes, and snippets.

@kuri65536
Created February 17, 2018 19:20
Show Gist options
  • Save kuri65536/09f081f01d8538edc95459e4e3d5e572 to your computer and use it in GitHub Desktop.
Save kuri65536/09f081f01d8538edc95459e4e3d5e572 to your computer and use it in GitHub Desktop.
FreeCAD Macro, Export Group to STL
# -*- coding: utf-8 -*-
import os
import FreeCAD
import Mesh
__objs__ = Gui.Selection.getSelection()
if len(__objs__) > 0:
fname = FreeCAD.ActiveDocument.FileName
dname = os.path.dirname(fname)
fname, fext = os.path.splitext(os.path.basename(fname))
seq = os.path.basename(fname).split("-") # versioning
if len(seq) > 1:
ver = "-" + seq[-1]
else:
ver = ""
for i in __objs__:
if "Group" not in str(i.TypeId):
continue
fname = i.Label
fname = os.path.join(dname, fname + ver + u".stl")
Mesh.export(__objs__, fname)
else:
print("no objects selected")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment