Changeset View
Changeset View
Standalone View
Standalone View
object_boolean_tools.py
| Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | for selObj in bpy.context.selected_objects: | ||||
| """ | """ | ||||
| for obj in bpy.context.scene.objects: | for obj in bpy.context.scene.objects: | ||||
| if isCanvas(obj): | if isCanvas(obj): | ||||
| for mod in obj.modifiers: | for mod in obj.modifiers: | ||||
| if(mod.name == "BTool_" + selObj.name): | if(mod.name == "BTool_" + selObj.name): | ||||
| obj.modifiers.remove(mod) | obj.modifiers.remove(mod) | ||||
| """ | """ | ||||
| if useWire: | if useWire: | ||||
| selObj.draw_type = "WIRE" | selObj.display_type = "WIRE" | ||||
| else: | else: | ||||
| selObj.draw_type = "BOUNDS" | selObj.display_type = "BOUNDS" | ||||
| cyclesVis.camera = False | cyclesVis.camera = False | ||||
| cyclesVis.diffuse = False | cyclesVis.diffuse = False | ||||
| cyclesVis.glossy = False | cyclesVis.glossy = False | ||||
| cyclesVis.shadow = False | cyclesVis.shadow = False | ||||
| cyclesVis.transmission = False | cyclesVis.transmission = False | ||||
| if _operation == "SLICE": | if _operation == "SLICE": | ||||
| # copies dupli_group property(empty), but group property is empty (users_group = None) | # copies dupli_group property(empty), but group property is empty (users_group = None) | ||||
| Show All 22 Lines | def Remove(context, thisObj_name, Prop): | ||||
| actObj = context.active_object | actObj = context.active_object | ||||
| # Restore the Brush | # Restore the Brush | ||||
| def RemoveThis(_thisObj_name): | def RemoveThis(_thisObj_name): | ||||
| for obj in bpy.context.scene.objects: | for obj in bpy.context.scene.objects: | ||||
| # if it's the brush object | # if it's the brush object | ||||
| if obj.name == _thisObj_name: | if obj.name == _thisObj_name: | ||||
| cyclesVis = obj.cycles_visibility | cyclesVis = obj.cycles_visibility | ||||
| obj.draw_type = "TEXTURED" | obj.display_type = "TEXTURED" | ||||
| del obj["BoolToolBrush"] | del obj["BoolToolBrush"] | ||||
| del obj["BoolTool_FTransform"] | del obj["BoolTool_FTransform"] | ||||
| cyclesVis.camera = True | cyclesVis.camera = True | ||||
| cyclesVis.diffuse = True | cyclesVis.diffuse = True | ||||
| cyclesVis.glossy = True | cyclesVis.glossy = True | ||||
| cyclesVis.shadow = True | cyclesVis.shadow = True | ||||
| cyclesVis.transmission = True | cyclesVis.transmission = True | ||||
| Show All 12 Lines | else: | ||||
| if Prop == "BRUSH": | if Prop == "BRUSH": | ||||
| Canvas = FindCanvas(actObj) | Canvas = FindCanvas(actObj) | ||||
| if Canvas: | if Canvas: | ||||
| for mod in Canvas.modifiers: | for mod in Canvas.modifiers: | ||||
| if ("BTool_" in mod.name): | if ("BTool_" in mod.name): | ||||
| if (actObj.name in mod.name): | if (actObj.name in mod.name): | ||||
| Canvas.modifiers.remove(mod) | Canvas.modifiers.remove(mod) | ||||
| cyclesVis = actObj.cycles_visibility | cyclesVis = actObj.cycles_visibility | ||||
| actObj.draw_type = "TEXTURED" | actObj.display_type = "TEXTURED" | ||||
| del actObj["BoolToolBrush"] | del actObj["BoolToolBrush"] | ||||
| del actObj["BoolTool_FTransform"] | del actObj["BoolTool_FTransform"] | ||||
| cyclesVis.camera = True | cyclesVis.camera = True | ||||
| cyclesVis.diffuse = True | cyclesVis.diffuse = True | ||||
| cyclesVis.glossy = True | cyclesVis.glossy = True | ||||
| cyclesVis.shadow = True | cyclesVis.shadow = True | ||||
| cyclesVis.transmission = True | cyclesVis.transmission = True | ||||
| ▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Lines | def modal(self, context, event): | ||||
| self.count += 1 | self.count += 1 | ||||
| actObj = bpy.context.active_object | actObj = bpy.context.active_object | ||||
| useWire = bpy.context.user_preferences.addons[__name__].preferences.use_wire | useWire = bpy.context.user_preferences.addons[__name__].preferences.use_wire | ||||
| if self.count == 1: | if self.count == 1: | ||||
| if isBrush(actObj) and actObj["BoolTool_FTransform"] == "True": | if isBrush(actObj) and actObj["BoolTool_FTransform"] == "True": | ||||
| EnableThisBrush(bpy.context, "False") | EnableThisBrush(bpy.context, "False") | ||||
| if useWire: | if useWire: | ||||
| actObj.draw_type = "WIRE" | actObj.display_type = "WIRE" | ||||
| else: | else: | ||||
| actObj.draw_type = "BOUNDS" | actObj.display_type = "BOUNDS" | ||||
| if self.operator == "Translate": | if self.operator == "Translate": | ||||
| bpy.ops.transform.translate('INVOKE_DEFAULT') | bpy.ops.transform.translate('INVOKE_DEFAULT') | ||||
| if self.operator == "Rotate": | if self.operator == "Rotate": | ||||
| bpy.ops.transform.rotate('INVOKE_DEFAULT') | bpy.ops.transform.rotate('INVOKE_DEFAULT') | ||||
| if self.operator == "Scale": | if self.operator == "Scale": | ||||
| bpy.ops.transform.resize('INVOKE_DEFAULT') | bpy.ops.transform.resize('INVOKE_DEFAULT') | ||||
| if event.type == 'LEFTMOUSE': | if event.type == 'LEFTMOUSE': | ||||
| if isBrush(actObj): | if isBrush(actObj): | ||||
| EnableThisBrush(bpy.context, "True") | EnableThisBrush(bpy.context, "True") | ||||
| actObj.draw_type = "WIRE" | actObj.display_type = "WIRE" | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| if event.type in {'RIGHTMOUSE', 'ESC'}: | if event.type in {'RIGHTMOUSE', 'ESC'}: | ||||
| if isBrush(actObj): | if isBrush(actObj): | ||||
| EnableThisBrush(bpy.context, "True") | EnableThisBrush(bpy.context, "True") | ||||
| actObj.draw_type = "WIRE" | actObj.display_type = "WIRE" | ||||
| return {'CANCELLED'} | return {'CANCELLED'} | ||||
| return {'RUNNING_MODAL'} | return {'RUNNING_MODAL'} | ||||
| def invoke(self, context, event): | def invoke(self, context, event): | ||||
| if context.object: | if context.object: | ||||
| context.window_manager.modal_handler_add(self) | context.window_manager.modal_handler_add(self) | ||||
| return {'RUNNING_MODAL'} | return {'RUNNING_MODAL'} | ||||
| ▲ Show 20 Lines • Show All 368 Lines • ▼ Show 20 Lines | |||||
| class VIEW3D_MT_booltool_menu(Menu): | class VIEW3D_MT_booltool_menu(Menu): | ||||
| bl_label = "BoolTool Operators" | bl_label = "BoolTool Operators" | ||||
| bl_idname = "VIEW3D_MT_booltool_menu" | bl_idname = "VIEW3D_MT_booltool_menu" | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| layout.label("Auto Boolean:") | layout.label("Auto Boolean:") | ||||
| layout.operator(OBJECT_OT_BoolTool_Auto_Difference.bl_idname, text='Difference', icon="ROTACTIVE") | layout.operator(OBJECT_OT_BoolTool_Auto_Difference.bl_idname, text='Difference', icon='PIVOT_ACTIVE') | ||||
| layout.operator(OBJECT_OT_BoolTool_Auto_Union.bl_idname, text='Union', icon="ROTATECOLLECTION") | layout.operator(OBJECT_OT_BoolTool_Auto_Union.bl_idname, text='Union', icon='PIVOT_INDIVIDUAL') | ||||
| layout.operator(OBJECT_OT_BoolTool_Auto_Intersect.bl_idname, text='Intersect', icon="ROTATECENTER") | layout.operator(OBJECT_OT_BoolTool_Auto_Intersect.bl_idname, text='Intersect', icon='PIVOT_MEDIAN') | ||||
| layout.operator(OBJECT_OT_BoolTool_Auto_Slice.bl_idname, text='Slice', icon="ROTATECENTER") | layout.operator(OBJECT_OT_BoolTool_Auto_Slice.bl_idname, text='Slice', icon='PIVOT_MEDIAN') | ||||
| layout.operator(OBJECT_OT_BoolTool_Auto_Subtract.bl_idname, text='Subtract', icon="ROTACTIVE") | layout.operator(OBJECT_OT_BoolTool_Auto_Subtract.bl_idname, text='Subtract', icon='PIVOT_ACTIVE') | ||||
| layout.separator() | layout.separator() | ||||
| layout.label("Brush Boolean:") | layout.label("Brush Boolean:") | ||||
| layout.operator(BTool_Diff.bl_idname, icon="ROTACTIVE") | layout.operator(BTool_Diff.bl_idname, icon='PIVOT_ACTIVE') | ||||
| layout.operator(BTool_Union.bl_idname, icon="ROTATECOLLECTION") | layout.operator(BTool_Union.bl_idname, icon='PIVOT_INDIVIDUAL') | ||||
| layout.operator(BTool_Inters.bl_idname, icon="ROTATECENTER") | layout.operator(BTool_Inters.bl_idname, icon='PIVOT_MEDIAN') | ||||
| layout.operator(BTool_Slice.bl_idname, icon="ROTATECENTER") | layout.operator(BTool_Slice.bl_idname, icon='PIVOT_MEDIAN') | ||||
| if (isCanvas(context.active_object)): | if (isCanvas(context.active_object)): | ||||
| layout.separator() | layout.separator() | ||||
| layout.operator(BTool_AllBrushToMesh.bl_idname, icon="MOD_LATTICE", text="Apply All") | layout.operator(BTool_AllBrushToMesh.bl_idname, icon="MOD_LATTICE", text="Apply All") | ||||
| Rem = layout.operator(BTool_Remove.bl_idname, icon="CANCEL", text="Remove All") | Rem = layout.operator(BTool_Remove.bl_idname, icon="CANCEL", text="Remove All") | ||||
| Rem.thisObj = "" | Rem.thisObj = "" | ||||
| Rem.Prop = "CANVAS" | Rem.Prop = "CANVAS" | ||||
| Show All 35 Lines | def draw(self, context): | ||||
| main.enabled = obj.type == 'MESH' and obs_len > 0 | main.enabled = obj.type == 'MESH' and obs_len > 0 | ||||
| main.separator() | main.separator() | ||||
| col = main.column(align=True) | col = main.column(align=True) | ||||
| col.enabled = obs_len > 1 | col.enabled = obs_len > 1 | ||||
| col.label("Auto Boolean:", icon="MODIFIER") | col.label("Auto Boolean:", icon="MODIFIER") | ||||
| col.separator() | col.separator() | ||||
| col.operator(OBJECT_OT_BoolTool_Auto_Difference.bl_idname, text='Difference', icon="ROTACTIVE") | col.operator(OBJECT_OT_BoolTool_Auto_Difference.bl_idname, text='Difference', icon='PIVOT_ACTIVE') | ||||
| col.operator(OBJECT_OT_BoolTool_Auto_Union.bl_idname, text='Union', icon="ROTATECOLLECTION") | col.operator(OBJECT_OT_BoolTool_Auto_Union.bl_idname, text='Union', icon='PIVOT_INDIVIDUAL') | ||||
| col.operator(OBJECT_OT_BoolTool_Auto_Intersect.bl_idname, text='Intersect', icon="ROTATECENTER") | col.operator(OBJECT_OT_BoolTool_Auto_Intersect.bl_idname, text='Intersect', icon='PIVOT_MEDIAN') | ||||
| main.separator() | main.separator() | ||||
| col = main.column(align=True) | col = main.column(align=True) | ||||
| col.enabled = obs_len == 2 | col.enabled = obs_len == 2 | ||||
| col.operator(OBJECT_OT_BoolTool_Auto_Slice.bl_idname, text='Slice', icon="ROTATECENTER") | col.operator(OBJECT_OT_BoolTool_Auto_Slice.bl_idname, text='Slice', icon='PIVOT_MEDIAN') | ||||
| col.operator(OBJECT_OT_BoolTool_Auto_Subtract.bl_idname, text='Subtract', icon="ROTACTIVE") | col.operator(OBJECT_OT_BoolTool_Auto_Subtract.bl_idname, text='Subtract', icon='PIVOT_ACTIVE') | ||||
| main.separator() | main.separator() | ||||
| col = main.column(align=True) | col = main.column(align=True) | ||||
| col.enabled = obs_len > 1 | col.enabled = obs_len > 1 | ||||
| col.label("Brush Boolean:", icon="MODIFIER") | col.label("Brush Boolean:", icon="MODIFIER") | ||||
| col.separator() | col.separator() | ||||
| col.operator(BTool_Diff.bl_idname, text="Difference", icon="ROTACTIVE") | col.operator(BTool_Diff.bl_idname, text="Difference", icon='PIVOT_ACTIVE') | ||||
| col.operator(BTool_Union.bl_idname, text="Union", icon="ROTATECOLLECTION") | col.operator(BTool_Union.bl_idname, text="Union", icon='PIVOT_INDIVIDUAL') | ||||
| col.operator(BTool_Inters.bl_idname, text="Intersect", icon="ROTATECENTER") | col.operator(BTool_Inters.bl_idname, text="Intersect", icon='PIVOT_MEDIAN') | ||||
| col.operator(BTool_Slice.bl_idname, text="Slice", icon="ROTATECENTER") | col.operator(BTool_Slice.bl_idname, text="Slice", icon='PIVOT_MEDIAN') | ||||
| main.separator() | main.separator() | ||||
| col = main.column(align=True) | col = main.column(align=True) | ||||
| col.label("Draw:", icon="MESH_CUBE") | col.label("Draw:", icon="MESH_CUBE") | ||||
| col.separator() | col.separator() | ||||
| col.operator(BTool_DrawPolyBrush.bl_idname, icon="LINE_DATA") | col.operator(BTool_DrawPolyBrush.bl_idname, icon="LINE_DATA") | ||||
| ▲ Show 20 Lines • Show All 476 Lines • Show Last 20 Lines | |||||