tarina_stl_export.py (7924B)
1 # exports each selected object into its own file 2 3 import bpy 4 import os 5 6 # export to blend file location 7 basedir = os.path.dirname(bpy.data.filepath) + '/' 8 9 if not basedir: 10 raise Exception("Blend file is not saved") 11 12 scene = bpy.context.scene 13 14 ##obj_active = scene.objects.active 15 selection = bpy.context.selected_objects 16 17 bpy.ops.object.select_all(action='DESELECT') 18 o = bpy.data.objects['Body'] 19 o.hide_set(False) 20 o.select_set(True) 21 o = bpy.data.objects['Body Support'] 22 o.hide_set(False) 23 o.select_set(True) 24 bpy.context.view_layer.objects.active = o 25 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-body.stl", check_existing=True, axis_forward='-Z', axis_up='-Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 26 bpy.ops.object.select_all(action='DESELECT') 27 28 bpy.ops.object.select_all(action='DESELECT') 29 o = bpy.data.objects['Left-Side'] 30 o.hide_set(False) 31 o.select_set(True) 32 bpy.context.view_layer.objects.active = o 33 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-left-side.stl", check_existing=True, axis_forward='-Y', axis_up='X', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 34 bpy.ops.object.select_all(action='DESELECT') 35 36 bpy.ops.object.select_all(action='DESELECT') 37 o = bpy.data.objects['Right-Side'] 38 o.hide_set(False) 39 o.select_set(True) 40 bpy.context.view_layer.objects.active = o 41 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-right-side.stl", check_existing=True, axis_forward='-Y', axis_up='-X', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 42 bpy.ops.object.select_all(action='DESELECT') 43 44 bpy.ops.object.select_all(action='DESELECT') 45 o = bpy.data.objects['Hdmi-Cap'] 46 o.hide_set(False) 47 o.select_set(True) 48 bpy.context.view_layer.objects.active = o 49 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-hdmi-cap.stl", check_existing=True, axis_forward='X', axis_up='Z', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 50 bpy.ops.object.select_all(action='DESELECT') 51 52 bpy.ops.object.select_all(action='DESELECT') 53 o = bpy.data.objects['Button-Plate-Bottom'] 54 o.hide_set(False) 55 o.select_set(True) 56 bpy.context.view_layer.objects.active = o 57 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-button-plate-bottom.stl", check_existing=True, axis_forward='X', axis_up='Z', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 58 bpy.ops.object.select_all(action='DESELECT') 59 60 bpy.ops.object.select_all(action='DESELECT') 61 o = bpy.data.objects['Button-Plate-Upper'] 62 o.hide_set(False) 63 o.select_set(True) 64 bpy.context.view_layer.objects.active = o 65 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-button-plate-upper.stl", check_existing=True, axis_forward='-X', axis_up='-Z', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 66 bpy.ops.object.select_all(action='DESELECT') 67 68 bpy.ops.object.select_all(action='DESELECT') 69 o = bpy.data.objects['Screen-Lid-hyperpixel'] 70 o.hide_set(False) 71 o.select_set(True) 72 bpy.context.view_layer.objects.active = o 73 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-screen-lid-hyperpixel.stl", check_existing=True, axis_forward='Z', axis_up='Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 74 bpy.ops.object.select_all(action='DESELECT') 75 76 bpy.ops.object.select_all(action='DESELECT') 77 o = bpy.data.objects['Screen-Lid-ugeek'] 78 o.hide_set(False) 79 o.select_set(True) 80 bpy.context.view_layer.objects.active = o 81 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-screen-lid-ugeek.stl", check_existing=True, axis_forward='Z', axis_up='Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 82 bpy.ops.object.select_all(action='DESELECT') 83 84 bpy.ops.object.select_all(action='DESELECT') 85 o = bpy.data.objects['Picamera-Bridge'] 86 o.hide_set(False) 87 o.select_set(True) 88 bpy.context.view_layer.objects.active = o 89 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-picamera-bridge.stl", check_existing=True, axis_forward='Y', axis_up='X', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 90 bpy.ops.object.select_all(action='DESELECT') 91 92 bpy.ops.object.select_all(action='DESELECT') 93 o = bpy.data.objects['Picamera-Body'] 94 o.hide_set(False) 95 o.select_set(True) 96 bpy.context.view_layer.objects.active = o 97 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-picamera-body.stl", check_existing=True, axis_forward='Z', axis_up='Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 98 bpy.ops.object.select_all(action='DESELECT') 99 100 bpy.ops.object.select_all(action='DESELECT') 101 o = bpy.data.objects['Picamera-Body-Lid'] 102 o.hide_set(False) 103 o.select_set(True) 104 bpy.context.view_layer.objects.active = o 105 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-picamera-body-lid.stl", check_existing=True, axis_forward='-Z', axis_up='-Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 106 bpy.ops.object.select_all(action='DESELECT') 107 108 bpy.ops.object.select_all(action='DESELECT') 109 o = bpy.data.objects['Picamera-HQ-Body'] 110 o.hide_set(False) 111 o.select_set(True) 112 bpy.context.view_layer.objects.active = o 113 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-picamera-hq-body.stl", check_existing=True, axis_forward='Z', axis_up='Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 114 bpy.ops.object.select_all(action='DESELECT') 115 116 bpy.ops.object.select_all(action='DESELECT') 117 o = bpy.data.objects['Picamera-HQ-Body-Lid'] 118 o.hide_set(False) 119 o.select_set(True) 120 bpy.context.view_layer.objects.active = o 121 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-picamera-hq-body-lid.stl", check_existing=True, axis_forward='-Z', axis_up='-Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 122 bpy.ops.object.select_all(action='DESELECT') 123 124 bpy.ops.object.select_all(action='DESELECT') 125 o = bpy.data.objects['Mic-Body'] 126 o.hide_set(False) 127 o.select_set(True) 128 bpy.context.view_layer.objects.active = o 129 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-mic-body.stl", check_existing=True, axis_forward='-Z', axis_up='-Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 130 bpy.ops.object.select_all(action='DESELECT') 131 132 bpy.ops.object.select_all(action='DESELECT') 133 o = bpy.data.objects['Mic-Lid'] 134 o.hide_set(False) 135 o.select_set(True) 136 bpy.context.view_layer.objects.active = o 137 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-mic-lid.stl", check_existing=True, axis_forward='Z', axis_up='Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 138 bpy.ops.object.select_all(action='DESELECT') 139 140 bpy.ops.object.select_all(action='DESELECT') 141 o = bpy.data.objects['picamera-screwhandle'] 142 o.hide_set(False) 143 o.select_set(True) 144 bpy.context.view_layer.objects.active = o 145 bpy.ops.export_mesh.stl(filepath=basedir + "tarina-picamera-screwhandle.stl", check_existing=True, axis_forward='Z', axis_up='Y', filter_glob="*.stl", use_selection=True, global_scale=1.0, use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF') 146 bpy.ops.object.select_all(action='DESELECT')