subassembly models setup from SDFormat file

This commit is contained in:
brothermechanic 2023-02-08 10:47:54 +03:00
parent 6af0f188a7
commit 95437a4527
No known key found for this signature in database
GPG key ID: BFB3FB14288FAC5E
7 changed files with 145 additions and 14 deletions

View file

@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
def export_stl(path, subdir="stl"):
def export_stl(path, subdir=""):
""" STL mesh exporter. Exports all objects in scene. """
for ob in bpy.context.scene.objects:
# deselect all but just one object and make it active
@ -24,14 +24,6 @@ def export_stl(path, subdir="stl"):
ob.select_set(state=True)
bpy.context.view_layer.objects.active = ob
filename = bpy.context.active_object.name
# create collision hull mesh
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.convex_hull()
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_add(type='DECIMATE')
bpy.context.object.modifiers["Decimate"].ratio = 0.2
# export stl
stl_path = os.path.join(path, subdir).replace('\\', '/')
if not os.path.isdir(stl_path):