Changeset View
Changeset View
Standalone View
Standalone View
io_mesh_stl/__init__.py
| Context not available. | |||||
| description="Apply the modifiers before saving", | description="Apply the modifiers before saving", | ||||
| default=True, | default=True, | ||||
| ) | ) | ||||
| join = BoolProperty( | |||||
| name="Join Objects", | |||||
| description="Join selected objects and export as single file", | |||||
| default=True, | |||||
| ) | |||||
| def execute(self, context): | def execute(self, context): | ||||
| Context not available. | |||||
| "filter_glob", | "filter_glob", | ||||
| "use_scene_unit", | "use_scene_unit", | ||||
| "use_mesh_modifiers", | "use_mesh_modifiers", | ||||
| "join" | |||||
| )) | )) | ||||
| scene = context.scene | scene = context.scene | ||||
| Context not available. | |||||
| to_up=self.axis_up, | to_up=self.axis_up, | ||||
| ).to_4x4() * Matrix.Scale(global_scale, 4) | ).to_4x4() * Matrix.Scale(global_scale, 4) | ||||
| faces = itertools.chain.from_iterable( | if self.join: | ||||
| faces = itertools.chain.from_iterable( | |||||
| blender_utils.faces_from_mesh(ob, global_matrix, self.use_mesh_modifiers) | blender_utils.faces_from_mesh(ob, global_matrix, self.use_mesh_modifiers) | ||||
| for ob in context.selected_objects) | for ob in context.selected_objects) | ||||
| stl_utils.write_stl(faces=faces, **keywords) | stl_utils.write_stl(faces=faces, **keywords) | ||||
| else: | |||||
| for ob in context.selected_objects: | |||||
| faces = blender_utils.faces_from_mesh(ob, global_matrix, self.use_mesh_modifiers) | |||||
| # unique name if we're writing each ob seperately | |||||
| (dir, basename) = os.path.split(self.filepath) | |||||
| (name, ext) = os.path.splitext(basename) | |||||
| filename = "%s-%s%s" % (name, bpy.path.clean_name(ob.name), ext) | |||||
| filepath = os.path.join(dir, filename) | |||||
| stl_utils.write_stl(faces=faces, filepath=filepath, ascii=self.ascii) | |||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| Context not available. | |||||