Changeset View
Changeset View
Standalone View
Standalone View
object_print3d_utils/export.py
| Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if image is not None: | ||||
| shutil.copy(imagepath, imagepath_dst) | shutil.copy(imagepath, imagepath_dst) | ||||
| except: | except: | ||||
| import traceback | import traceback | ||||
| traceback.print_exc() | traceback.print_exc() | ||||
| def write_mesh(context, info, report_cb): | def write_mesh(context, info, report_cb): | ||||
| scene = context.scene | scene = context.scene | ||||
| layer = context.view_layer | |||||
| unit = scene.unit_settings | unit = scene.unit_settings | ||||
| print_3d = scene.print_3d | print_3d = scene.print_3d | ||||
| obj_base = scene.object_bases.active | # obj_base = layer.object_bases.active | ||||
| obj = obj_base.object | obj = layer.objects.active | ||||
| export_format = print_3d.export_format | export_format = print_3d.export_format | ||||
| global_scale = unit.scale_length if (unit.system != 'NONE' and print_3d.use_apply_scale) else 1.0 | global_scale = unit.scale_length if (unit.system != 'NONE' and print_3d.use_apply_scale) else 1.0 | ||||
| path_mode = 'COPY' if print_3d.use_export_texture else 'AUTO' | path_mode = 'COPY' if print_3d.use_export_texture else 'AUTO' | ||||
| context_override = context.copy() | context_override = context.copy() | ||||
| obj_base_tmp = None | obj_base_tmp = None | ||||
| # PLY can only export single mesh objects! | # PLY can only export single mesh objects! | ||||
| if export_format == 'PLY': | if export_format == 'PLY': | ||||
| context_backup = context.copy() | context_backup = context.copy() | ||||
| bpy.ops.object.mode_set(mode='OBJECT', toggle=False) | bpy.ops.object.mode_set(mode='OBJECT', toggle=False) | ||||
| from . import mesh_helpers | from . import mesh_helpers | ||||
| obj_base_tmp = mesh_helpers.object_merge(context, context_override["selected_objects"]) | obj_tmp = mesh_helpers.object_merge(context, context_override["selected_objects"]) | ||||
| context_override["active_object"] = obj_base_tmp.object | context_override["active_object"] = obj_tmp | ||||
| context_override["selected_bases"] = [obj_base_tmp] | # context_override["selected_bases"] = [obj_base_tmp] | ||||
| context_override["selected_objects"] = [obj_base_tmp.object] | context_override["selected_objects"] = [obj_tmp] | ||||
| else: | else: | ||||
| # XXX28 | |||||
| ''' | |||||
| if obj_base not in context_override["selected_bases"]: | if obj_base not in context_override["selected_bases"]: | ||||
| context_override["selected_bases"].append(obj_base) | context_override["selected_bases"].append(obj_base) | ||||
| ''' | |||||
| if obj not in context_override["selected_objects"]: | if obj not in context_override["selected_objects"]: | ||||
| context_override["selected_objects"].append(obj) | context_override["selected_objects"].append(obj) | ||||
| export_path = bpy.path.abspath(print_3d.export_path) | export_path = bpy.path.abspath(print_3d.export_path) | ||||
| # Create name 'export_path/blendname-objname' | # Create name 'export_path/blendname-objname' | ||||
| # add the filename component | # add the filename component | ||||
| if bpy.data.is_saved: | if bpy.data.is_saved: | ||||
| ▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines | |||||