def invoke(self, context, event): if 'Articulator' in bpy.data.objects: art_arm = bpy.data.objects.get('Articulator') if art_arm.get('bennet_angle'): self.bennet_angle = art_arm.get('bennet_angle') if art_arm.get('intra_condyl_width'): self.intra_condyle_width = art_arm['intra_condyly_width'] if art_arm.get('incisal_guidance'): self.incisal_guidance = art_arm['incisal_guidance'] if art_arm.get('canine_guidance'): self.canine_guidance = art_arm['canine_guidance'] if art_arm.get('condyle_angle'): self.condyle_angle = art_arm['condyle_angle'] if art_arm.get('guidance_delay_ant'): self.guidance_delay_ant = art_arm['guidance_delay_ant'] if art_arm.get('guidance_delay_lat'): self.guidance_delay_lat = art_arm['guidance_delay_lat'] else: settings = get_settings() self.intra_condyle_width = settings.def_intra_condyle_width self.condyle_angle = settings.def_condyle_angle self.bennet_angle = settings.def_bennet_angle self.incisal_guidance = settings.def_incisal_guidance self.canine_guidance = settings.def_canine_guidance self.guidance_delay_ant = settings.def_guidance_delay_ant self.guidance_delay_lat = settings.def_guidance_delay_lat return context.window_manager.invoke_props_dialog(self)
def register(bl_info): Tracker.initialize(appurl="https://occlusal-guard-beta.firebaseio.com", version=str(bl_info["version"])) prefs = get_settings() if prefs.dev == True: Tracker.dev = True else: Tracker.dev = False if Tracker.dev == True: Tracker.verbose = False Tracker.background = True # test either way Tracker.failsafe = False # test either way Tracker.tracking_enabled = True # enabled automatically for testing else: Tracker.verbose = False Tracker.background = True Tracker.failsafe = True Tracker.tracking_enabled = True # User accepted on download if not internet(): print('no internet') return # try running install trackInstalled()
def register(bl_info): # will launch backgorund thread which tracks install Tracker.initialize_bg_and_track_install( appurl="https://occlusal-guard-beta.firebaseio.com", version=str(bl_info["version"]), track_install=True) prefs = get_settings() if prefs.dev == True: Tracker.dev = True else: Tracker.dev = False if Tracker.dev == True: Tracker.verbose = False Tracker.background = True # test either way Tracker.failsafe = False # test either way Tracker.tracking_enabled = True # enabled automatically for testing else: Tracker.verbose = False Tracker.background = True Tracker.failsafe = True Tracker.tracking_enabled = True # User accepted on download
def execute(self, context): settings = get_settings() dbg = settings.debug #if bpy.context.mode != 'OBJECT': # bpy.ops.object.mode_set(mode = 'OBJECT') sce = context.scene world_mx = Matrix.Identity(4) world_mx[0][3]=sce.cursor_location[0] world_mx[1][3]=sce.cursor_location[1] world_mx[2][3]=sce.cursor_location[2] #is this more memory friendly than listing all objects? current_obs = [ob.name for ob in bpy.data.objects] #link the new implant from the library obj_from_lib(settings.ortho_lib,self.ob) #this is slightly more robust than trusting we don't have duplicate names. for ob in bpy.data.objects: if ob.name not in current_obs: Bracket = ob sce.objects.link(Bracket) rv3d = context.region_data view_mx = rv3d.view_rotation.to_matrix() Bracket.matrix_world = world_mx * view_mx.to_4x4() return {'FINISHED'}
def invoke(self, context, event): settings = get_settings() self.resolution = settings.def_condylar_resolution self.range_of_motion = settings.def_range_of_motion return context.window_manager.invoke_props_dialog(self)
def invoke(self, context, event): self.objs.clear() settings = get_settings() libpath = settings.ortho_lib assets = obj_list_from_lib(libpath) for asset_object_name in assets: self.objs.add().name = asset_object_name context.window_manager.invoke_search_popup(self) return {'FINISHED'}
def plane_cut_draw_callback(self, context): self.crv.draw(context) self.help_box.draw() prefs = get_settings() r,g,b = prefs.active_region_color outline_region(context.region,(r,g,b,1)) if len(self.new_geom_draw_points): common_drawing.draw_3d_points(context, self.new_geom_draw_points, self.new_geom_color, 4) common_drawing.draw_3d_points(context, [self.new_geom_point], self.new_geom_point_color, 10)
def quick_lic_check(): prefs = get_settings() license_ley = prefs.heal_license_key raw_key = license_ley.replace('-', '') if len(raw_key) == 0: res = {'status': 'FAILED'} elif len(raw_key) != 16: res = {'status': 'FAILED'} else: res = checkLicense(raw_key) return res
def __init__(self, context, bracket_data_manager): ''' Gets info from bracket manager and siplays orthogonal slices on the snap object ''' if not bracket_data_manager.bracket_obj: return None elif not bracket_data_manager.snap_ob: return None self.bracket_data = bracket_data_manager ob = self.bracket_data.snap_ob bme = bmesh.new() bme.from_object(ob, context.scene) self.snap_ob = ob self.bme = bme self.bvh = BVHTree.FromBMesh(self.bme) self.cut_pt = None self.cut_no_x = None self.cut_no_y = None self.slice_points_x = [] self.slice_points_y = [] self.reference_L = [] self.points_2d = [] self.active_point_2d = Vector((0,0,0)) self.mx = self.bracket_data.bracket_obj.matrix_world.to_3x3() b_gauge = self.bracket_data.bracket_obj.get('bracket_gauge') if b_gauge and not get_settings().bgauge_override: #read the prescription value from the objects self.b_gauge = b_gauge else: #override the rx value self.b_gauge = get_settings().bracket_gauge
def invoke(self, context, event): settings = get_settings() libpath = settings.ortho_lib assets = obj_list_from_lib(libpath) if settings.bracket in assets: current_obs = [ob.name for ob in bpy.data.objects] obj_from_lib(settings.ortho_lib,settings.bracket) for ob in bpy.data.objects: if ob.name not in current_obs: Bracket = ob Bracket.hide = False context.scene.objects.link(Bracket) else: Bracket = None if context.object and context.object.type == 'MESH': self.bracket_manager = BracketDataManager(context,snap_type ='OBJECT', snap_object = context.object, name = 'Bracket', bracket = Bracket) self.bracket_slicer = BracektSlicer(context, self.bracket_manager) else: self.bracket_manager = BracketDataManager(context,snap_type ='SCENE', snap_object = None, name = 'Bracket', bracket = Bracket) self.bracket_slicer = None help_txt = "DRAW MARGIN OUTLINE\n\nLeft Click on model to place bracket.\n G to grab \n S to show slice \n ENTER to confirm \n ESC to cancel" self.help_box = TextBox(context,500,500,300,200,10,20,help_txt) self.help_box.snap_to_corner(context, corner = [1,1]) self.mode = 'start' self._handle = bpy.types.SpaceView3D.draw_handler_add(bracket_placement_draw_callback, (self, context), 'WINDOW', 'POST_PIXEL') context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'}
def draw(self, context): sce = bpy.context.scene layout = self.layout prefs = get_settings() row = layout.row() row.label(text="Model Labelling") #row.operator("wm.url_open", text = "", icon="INFO").url = "https://github.com/patmo141/odc_public/wiki" if context.object != None: row = layout.row() txt = context.object.name row.label(text="Selected Model: " + txt) else: row = layout.row() row.label(text="Please Select a Model") #row = layout.row() #row.label(text = 'SVG Image Workflow') row = layout.row() row.label(text='Add Text to Object') row = layout.row() col = row.column() col.prop(prefs, "d3_model_label", text='') col.prop(prefs, "d3_model_label_depth", text='Text Depth') row = layout.row() row.operator("d3splint.stencil_text", text='Stencil Text Label') row = layout.row() row.operator("d3tool.remesh_and_emboss_text", text='Emboss All Labels onto Object') row = layout.row() row.operator("d3splint.splint_finalize_labels", text='Finalize Label Modifiers')
def execute(self, context): n = context.scene.odc_splint_index splint = context.scene.odc_splints[n] prefs = get_settings() if not prefs.non_clinical_use: self.report({'ERROR'}, 'You must certify non-clinical use in your addon preferences or in the panel') return {'CANCELLED'} if splint.finalize_splint: self.report({'WARNING'}, 'You have already finalized, this will remove or alter existing modifiers and try again') if self.solver == 'CORK': self.report({'ERROR'}, 'The Cork engine has not been set up with this new method') return {'CANCELLED'} Shell = bpy.data.objects.get('Splint Shell') Refractory = bpy.data.objects.get('Refractory Model') if Shell == None: self.report({'ERROR'}, 'Need to calculate splint shell first') return {'CANCELLED'} if Refractory == None: self.report({'ERROR'}, 'Need to make refractory model first') return {'CANCELLED'} if context.mode != 'OBJECT': bpy.ops.object.mode_set(mode = 'OBJECT') start = time.time() #don't add multiple boolean modifiers if 'Final Splint' not in bpy.data.objects: me = Shell.to_mesh(context.scene, apply_modifiers = True, settings = 'PREVIEW') ob = bpy.data.objects.new('Final Splint', me) context.scene.objects.link(ob) ob.matrix_world = Shell.matrix_world else: ob = bpy.data.objects.get('Final Splint') me = ob.data a_base = bpy.data.objects.get('Auto Base') if 'Trim Base' in ob.modifiers and a_base != None: mod = ob.modifiers.get('Trim Base') mod.object = a_base mod.operation = 'DIFFERENCE' mod.solver = self.solver else: mod = ob.modifiers.new('Trim Base', type = 'BOOLEAN') mod.object = a_base mod.operation = 'DIFFERENCE' mod.solver = self.solver #Final Spint need only 1 boolean operation if 'Refractory Model' in ob.modifiers: mod = ob.modifiers.get('Passive Spacer') else: mod = ob.modifiers.new('Refractory Model', type = 'BOOLEAN') mod.object = Refractory mod.operation = 'DIFFERENCE' mod.solver = self.solver for obj in context.scene.objects: obj.hide = True context.scene.objects.active = ob ob.select = True ob.hide = False ob.update_tag() context.scene.update() completion_time = time.time() - start print('competed the boolean subtraction in %f seconds' % completion_time) splint.finalize_splint = True splint.ops_string += 'Finalize Splint:' tracking.trackUsage("D3Splint:FinishBoolean3",(self.solver, str(completion_time)[0:4])) tmodel = bpy.data.objects.get('Trimmed_Model') #make sure user can verify no intersections if tmodel: tmodel.hide = False context.space_data.show_backface_culling = False return {'FINISHED'}
def execute(self, context): n = context.scene.odc_splint_index splint = context.scene.odc_splints[n] prefs = get_settings() if not prefs.non_clinical_use: self.report({'ERROR'}, 'You must certify non-clinical use in your addon preferences or in the panel') return {'CANCELLED'} if splint.finalize_splint: self.report({'WARNING'}, 'You have already finalized, this will remove or alter existing modifiers and try again') Shell = bpy.data.objects.get('Splint Shell') Passive = bpy.data.objects.get('Passive Spacer') Blockout = bpy.data.objects.get('Blockout Wax') if Shell == None: self.report({'ERROR'}, 'Need to calculate splint shell first') return {'CANCELLED'} if Passive == None: self.report({'ERROR'}, 'Need to make passive spacer first') return {'CANCELLED'} if Blockout == None and self.use_blockout == True: self.report({'ERROR'}, 'Need to blockout trimmed model first') return {'CANCELLED'} if context.mode != 'OBJECT': bpy.ops.object.mode_set(mode = 'OBJECT') start = time.time() #don't add multiple boolean modifiers if 'Final Splint' not in bpy.data.objects: me = Shell.to_mesh(context.scene, apply_modifiers = True, settings = 'PREVIEW') ob = bpy.data.objects.new('Final Splint', me) context.scene.objects.link(ob) ob.matrix_world = Shell.matrix_world else: ob = bpy.data.objects.get('Final Splint') me = ob.data a_base = bpy.data.objects.get('Auto Base') if 'Trim Base' in ob.modifiers and a_base != None: mod = ob.modifiers.get('Trim Base') mod.object = a_base mod.operation = 'DIFFERENCE' mod.solver = self.solver1 else: mod = ob.modifiers.new('Trim Base', type = 'BOOLEAN') mod.object = a_base mod.operation = 'DIFFERENCE' mod.solver = self.solver1 if self.method_order == 'JOIN': #Structure is Shell - (Blockout + Passive) #Blockout Wax Needs a union modifier if 'Join Passive' in Blockout.modifiers: mod = Blockout.modifiers.get('Join Passive') mod.object = Passive mod.operation = 'UNION' mod.solver = self.solver1 else: mod = Blockout.modifiers.new('Join Passive', type = 'BOOLEAN') mod.object = Passive mod.operation = 'UNION' mod.solver = self.solver1 #Final Spint need only 1 boolean operation if 'Passive Spacer' in ob.modifiers: mod = ob.modifiers.get('Passive Spacer') ob.modifiers.remove(mod) if 'Subtract Blockout' in ob.modifiers: mod = ob.modifiers.get('Subtract Blockout') mod.object = Blockout mod.operation = 'DIFFERENCE' mod.solver = self.solver2 else: mod = ob.modifiers.new('Subtract Blockout', type = 'BOOLEAN') mod.object = Blockout mod.operation = 'DIFFERENCE' mod.solver = self.solver2 elif self.method_order == 'SUBTRACT': #Strucure is #Shell - Blockout - Passive #Blockout Wax MUST NOT have modifier if 'Join Passive' in Blockout.modifiers: mod = Blockout.modifiers.get('Join Passive') Blockout.modifiers.remove(mod) Blockout.update_tag() if 'Subtract Blockout' in ob.modifiers: mod = ob.modifiers.get('Subtract Blockout') mod.object = Blockout mod.operation = 'DIFFERENCE' mod.solver = self.solver1 else: mod = ob.modifiers.new('Subtract Blockout', type = 'BOOLEAN') mod.object = Blockout mod.operation = 'DIFFERENCE' mod.solver = self.solver1 if 'Passive Spacer' not in ob.modifiers: bool_mod = ob.modifiers.new('Passive Spacer', type = 'BOOLEAN') bool_mod.operation = 'DIFFERENCE' bool_mod.object = Passive bool_mod.solver = self.solver2 #Bmesh is too likely to create bad cuts else: bool_mod = ob.modifiers.get('Passive Spacer') bool_mod.operation = 'DIFFERENCE' bool_mod.object = Passive bool_mod.solver = self.solver2 ##Bmesh is too likely to create bad cuts for obj in context.scene.objects: obj.hide = True context.scene.objects.active = ob ob.select = True ob.hide = False ob.update_tag() context.scene.update() completion_time = time.time() - start print('competed the boolean subtraction in %f seconds' % completion_time) splint.finalize_splint = True tracking.trackUsage("D3Splint:FinishBoolean",(self.solver1,self.solver2, self.method_order, str(completion_time)[0:4])) tmodel = bpy.data.objects.get('Trimmed_Model') #make sure user can verify no intersections if tmodel: tmodel.hide = False return {'FINISHED'}
def execute(self, context): n = context.scene.odc_splint_index splint = context.scene.odc_splints[n] prefs = common_utilities.get_settings() if not prefs.non_clinical_use: self.report({'ERROR'}, 'You must certify non-clinical use in your addon preferences or in the panel') return {'CANCELLED'} if splint.finalize_splint: self.report({'WARNING'}, 'You have already finalized, this will remove or alter existing modifiers and try again') Shell = bpy.data.objects.get('Splint Shell') Passive = bpy.data.objects.get('Passive Spacer') if Shell == None: self.report({'ERROR'}, 'Need to calculate splint shell first') return {'CANCELLED'} if Passive == None: self.report({'ERROR'}, 'Need to make passive spacer first') return {'CANCELLED'} if context.mode != 'OBJECT': bpy.ops.object.mode_set(mode = 'OBJECT') tracking.trackUsage("D3Splint:FinishBoolean",None) #don't add multiple boolean modifiers if 'Passive Fit' not in Shell.modifiers: bool_mod = Shell.modifiers.new('Passive Fit', type = 'BOOLEAN') bool_mod.operation = 'DIFFERENCE' bool_mod.solver = self.solver #update in case they changed the spacer bool_mod.object = Passive Passive.hide = True bme = bmesh.new() bme.from_object(Shell, context.scene) bme.faces.ensure_lookup_table() bme.verts.ensure_lookup_table() total_faces = set(bme.faces[:]) islands = [] iters = 0 while len(total_faces) and iters < 100: iters += 1 seed = total_faces.pop() island = flood_selection_faces(bme, {}, seed, max_iters = 10000) islands += [island] total_faces.difference_update(island) best = max(islands, key = len) total_faces = set(bme.faces[:]) del_faces = total_faces - best bmesh.ops.delete(bme, geom = list(del_faces), context = 3) del_verts = [] for v in bme.verts: if all([f in del_faces for f in v.link_faces]): del_verts += [v] bmesh.ops.delete(bme, geom = del_verts, context = 1) del_edges = [] for ed in bme.edges: if len(ed.link_faces) == 0: del_edges += [ed] bmesh.ops.delete(bme, geom = del_edges, context = 4) if 'Final Splint' not in bpy.data.objects: me = bpy.data.meshes.new('Final Splint') ob = bpy.data.objects.new('Final Splint', me) context.scene.objects.link(ob) ob.matrix_world = Shell.matrix_world else: ob = bpy.data.objects.get('Final Splint') me = ob.data bme.to_mesh(me) bme.free() for obj in context.scene.objects: obj.hide = True context.scene.objects.active = ob ob.select = True ob.hide = False tmodel = bpy.data.objects.get('Trimmed_Model') #make sure user can verify no intersections if tmodel: tmodel.hide = False splint.finalize_splint = True context.space_data.show_backface_culling = False return {'FINISHED'}
def landmarks_draw_callback(self, context): self.crv.draw(context) self.help_box.draw() prefs = get_settings() r,g,b = prefs.active_region_color outline_region(context.region,(r,g,b,1))
def execute(self, context): n = context.scene.odc_splint_index splint = context.scene.odc_splints[n] prefs = get_settings() if not prefs.non_clinical_use: self.report({'ERROR'}, 'You must certify non-clinical use in your addon preferences or in the panel') return {'CANCELLED'} if splint.finalize_splint: self.report({'WARNING'}, 'You have already finalized, this will remove or alter existing modifiers and try again') if splint.workflow_type != 'BITE_POSITIONER': self.report({'ERROR'}, 'This splint is not a bite positioner workflow, change it to use this function') return {'CANCELLED'} Shell = bpy.data.objects.get('Splint Shell') Maxilla = bpy.data.objects.get(splint.get_maxilla()) Mandible = bpy.data.objects.get(splint.get_mandible()) if Shell == None: self.report({'ERROR'}, 'Need to calculate the bite wafer first') return {'CANCELLED'} if Maxilla == None: self.report({'ERROR'}, 'Need to mark the maxillary modelfirst') return {'CANCELLED'} if Mandible == None: self.report({'ERROR'}, 'Need to mark the mandible first') return {'CANCELLED'} if context.mode != 'OBJECT': bpy.ops.object.mode_set(mode = 'OBJECT') start = time.time() #don't add multiple boolean modifiers if 'Final Splint' not in bpy.data.objects: me = Shell.to_mesh(context.scene, apply_modifiers = True, settings = 'PREVIEW') ob = bpy.data.objects.new('Final Splint', me) context.scene.objects.link(ob) ob.matrix_world = Shell.matrix_world else: ob = bpy.data.objects.get('Final Splint') me = ob.data #Blockout Wax Needs a union modifier if 'Subtract Mandible' in ob.modifiers: mod = ob.modifiers.get('Subtract Mandible') mod.object = Mandible mod.operation = 'DIFFERENCE' mod.solver = self.solver else: mod = ob.modifiers.new('Subtract Mandible', type = 'BOOLEAN') mod.object = Mandible mod.operation = 'DIFFERENCE' mod.solver = self.solver if 'Subtract Maxilla' in ob.modifiers: mod = ob.modifiers.get('Subtract Maxilla') mod.object = Maxilla mod.operation = 'DIFFERENCE' mod.solver = self.solver else: mod = ob.modifiers.new('Subtract Maxilla', type = 'BOOLEAN') mod.object = Maxilla mod.operation = 'DIFFERENCE' mod.solver = self.solver for obj in context.scene.objects: obj.hide = True context.scene.objects.active = ob ob.select = True ob.hide = False completion_time = time.time() - start print('competed the boolean subtraction in %f seconds' % completion_time) splint.finalize_splint = True tracking.trackUsage("D3Splint:FinishBiteBoolean",(self.solver, str(completion_time)[0:4])) return {'FINISHED'}
def draw(self, context): prefs = get_settings() sce = bpy.context.scene layout = self.layout row = layout.row() row.label(text="Model Operators") row.operator("wm.url_open", text="", icon="INFO").url = "https://d3tool.com/knowledge-base/" if context.object != None: row = layout.row() txt = context.object.name row.label(text="Selected Model: " + txt) else: row = layout.row() row.label(text="Please Select a Model") row = layout.row() row.label('Sculpt/Paint Mode Tools') row = layout.row() col = row.column() col.operator("d3splint.enter_sculpt_paint_mask", text="Paint Model") col.operator("paint.mask_flood_fill", text="Clear Paint").mode = 'VALUE' col.operator("d3splint.delete_sculpt_mask", text="Delete Painted") #defaults to .value = 0 col.operator("d3splint.close_paint_hole", text='Close Paint Hole') col.operator("d3splint.delete_sculpt_mask_inverse", text="Keep Only Painted") if context.mode == 'SCULPT': col.operator("object.mode_set", text='Finish Sculpt/Paint') row = layout.row() row.label('Fixing and Cleaning Operators') row = layout.row() row.operator("d3model.remesh_and_decimate", text="Auto Remesh") row = layout.row() #col.operator("d3splint.simple_offset_surface", text = "Simple Offset") row.prop(prefs, "d3_model_auto_fill_small") row.prop(prefs, "d3_model_max_hole_size") row = layout.row() col = row.column() col.operator("d3model.mesh_repair", text="Fix Holes and Islands") col.operator("d3splint.delete_islands", text="Delete Loose Parts") col.operator("d3splint.ragged_edges", text="Remove Ragged Edges") row = layout.row() row.label('Open Model Cutting') row = layout.row() col = row.column() col.operator("d3splint.splint_plane_cut", text="Plane Cut Open Model").cut_method = "SURFACE" row = layout.row() row.label('Close Model Cutting') row = layout.row() col = row.column() col.operator("d3splint.splint_plane_cut", text="Plane Cut Closed Model").cut_method = "SOLID" col.operator("d3splint.splint_pause_plane_cuts", text="De-Activate Cuts") col.operator("d3splint.splint_activate_plane_cuts", text="Re-Activate Cuts") col.operator("d3splint.splint_finalize_plane_cuts", text="Apply All Cuts") row = layout.row() row.label('Base and Thickness Operators') row = layout.row() col = row.column() col.operator("d3splint.simple_base", text="Simple Base") #col.operator("d3splint.model_wall_thicken", text = 'Hollow Model') col.operator("d3splint.model_wall_thicken2", text='Hollow Model') col.operator("d3tool.model_vertical_base", text='Vertical Base') row = layout.row() row.label('Batch Processing') row = layout.row() col = row.column() col.operator("d3splint.batch_process_plane_cuts", text='Batch Plane Cuts')
def execute(self, context): n = context.scene.odc_splint_index splint = context.scene.odc_splints[n] prefs = get_settings() start = time.time() Shell = bpy.data.objects.get('Final Splint') if Shell == None: self.report({'ERROR'}, 'Need to calculate the finalize the splint first') return {'CANCELLED'} bme = bmesh.new() bme.from_object(Shell, context.scene) bme.verts.ensure_lookup_table() bme.edges.ensure_lookup_table() bme.faces.ensure_lookup_table() islands = bmesh_loose_parts(bme, selected_faces = None, max_iters = 100) if len(islands) == 1: print('there is only one solid part') Shell.modifiers.clear() bme.to_mesh(Shell.data) bme.free() return {'FINISHED'} best_island = max(islands, key = len) to_keep = set(best_island) total_faces = set(bme.faces[:]) del_faces = total_faces - to_keep bmesh.ops.delete(bme, geom = list(del_faces), context = 3) del_verts = [] #There has GOT to be a smarter way. Maybe by iterating over del_faces? for v in bme.verts: if all([f in del_faces for f in v.link_faces]): del_verts += [v] bmesh.ops.delete(bme, geom = del_verts, context = 1) del_edges = [] for ed in bme.edges: if len(ed.link_faces) == 0: del_edges += [ed] bmesh.ops.delete(bme, geom = del_edges, context = 4) Shell.modifiers.clear() bme.to_mesh(Shell.data) bme.free() finish = time.time() print('took %f seconds to clean islands' % (finish - start)) completion_time = time.time() - start print('Applied all modifiers and removed islands in %f seconds' % completion_time) tracking.trackUsage("D3Splint:RemoveIslands",str(completion_time)[0:4]) return {'FINISHED'}
def invoke(self,context, event): label_message = get_settings().d3_model_label Model = context.object for ob in bpy.data.objects: if "D3T Label" in ob.name: continue ob.select = False ob.hide = True Model.select = True Model.hide = False #bpy.ops.view3d.view_selected() self.crv = TextLineDrawer(context,snap_type ='OBJECT', snap_object = Model, msg = label_message) context.space_data.fx_settings.use_ssao = True #TODO, tweak the modifier as needed help_txt = "INTERACTIVE LABEL STENCIL\n\n- LeftClick and move mouse to define a line across your model \n- The line will stick to your mouse until you Left Click again\n- A preview of the text label will follow your line\n -press 'ENTER' to project the text onto your model and finish the operator.\n\nADVANCED USAGE\n\n-RightMouse in the middle of the label to snap your view perpendicular to the model surface, you may need to adjust the position slightly\n- You can press 'P' to project the text onto the object without leaving the operator. You can then alter your view to inspect the text projection.\n- LEFT_ARROW key to snap back to the original view, you can then modify your viewing angle and press 'P' again. When satisfied, press 'ENTER' to finish." self.help_box = TextBox(context,500,500,300,200,10,20,help_txt) self.help_box.snap_to_corner(context, corner = [1,1]) self.bme= bmesh.new() self.bme.from_mesh(Model.data) self.ob = Model self.cursor_updated = True #get new text data and object in the scene self.txt_crv = bpy.data.curves.new("D3T Label", type = 'FONT') self.txt_crv_ob = bpy.data.objects.new("D3T Label", self.txt_crv) context.scene.objects.link(self.txt_crv_ob) context.scene.update() self.txt_crv_ob.hide = True self.txt_me_data = self.txt_crv_ob.to_mesh(context.scene, apply_modifiers = True, settings = 'PREVIEW') self.txt_me_ob = bpy.data.objects.new("D3T Label Mesh", self.txt_me_data) context.scene.objects.link(self.txt_me_ob) self.txt_crv.align_x = 'LEFT' self.txt_crv.align_y = 'BOTTOM' self.txt_crv.body = label_message #TODO hook up to property context.space_data.show_manipulator = False self.mode = 'main' self._handle = bpy.types.SpaceView3D.draw_handler_add(stencil_text_callback, (self, context), 'WINDOW', 'POST_PIXEL') context.window_manager.modal_handler_add(self) v3d = context.space_data rv3d = v3d.region_3d self.last_view_rot = rv3d.view_rotation self.last_view_loc = rv3d.view_location self.last_view_matrix = rv3d.view_matrix.copy() self.last_view_distance = rv3d.view_distance return {'RUNNING_MODAL'}