Bool Tool: New options (Arrange modifier, Show expanded) #104907
@ -4,8 +4,8 @@
|
||||
|
||||
bl_info = {
|
||||
"name": "Bool Tool",
|
||||
"author": "Vitor Balbio, Mikhail Rachinskiy, TynkaTopi, Meta-Androcto, Simon Appelt",
|
||||
"version": (0, 4, 1),
|
||||
"author": "Vitor Balbio, Mikhail Rachinskiy, TynkaTopi, Meta-Androcto, Simon Appelt, Christopher Kwiatkowski",
|
||||
"version": (0, 5, 0),
|
||||
"blender": (2, 80, 0),
|
||||
"location": "View3D > Sidebar > Edit Tab",
|
||||
"description": "Bool Tool Hotkey: Ctrl Shift B",
|
||||
@ -106,11 +106,24 @@ def ConvertToMesh(obj):
|
||||
bpy.context.view_layer.objects.active = act
|
||||
|
||||
|
||||
# Moves the modifier under the nearest higher boolean
|
||||
def ArrangeModifier(object, boolean_modifier):
|
||||
modifiers = object.modifiers
|
||||
|
||||
index = modifiers.find(boolean_modifier.name)
|
||||
while index > 0 and modifiers[index - 1].type != 'BOOLEAN':
|
||||
modifiers.move(index, index - 1)
|
||||
index -= 1
|
||||
|
||||
|
||||
# Do the Union, Difference and Intersection Operations with a Brush
|
||||
def Operation(context, _operation):
|
||||
prefs = context.preferences.addons[__name__].preferences
|
||||
useWire = prefs.use_wire
|
||||
|
||||
arrangeCheckbox = context.scene.ArrangeModifier
|
||||
showExpanded = context.scene.ShowExpanded
|
||||
|
||||
for selObj in context.selected_objects:
|
||||
if (
|
||||
selObj != context.active_object and
|
||||
@ -142,10 +155,18 @@ def Operation(context, _operation):
|
||||
sliceMod = clone.modifiers.new("BTool_" + selObj.name, "BOOLEAN") # add mod to clone obj
|
||||
sliceMod.object = selObj
|
||||
sliceMod.operation = "DIFFERENCE"
|
||||
if not showExpanded:
|
||||
sliceMod.show_expanded = False
|
||||
if arrangeCheckbox:
|
||||
ArrangeModifier(actObj, sliceMod)
|
||||
clone["BoolToolRoot"] = True
|
||||
|
||||
newMod = actObj.modifiers.new("BTool_" + selObj.name, "BOOLEAN")
|
||||
newMod.object = selObj
|
||||
if not showExpanded:
|
||||
newMod.show_expanded = False
|
||||
if arrangeCheckbox:
|
||||
ArrangeModifier(actObj, newMod)
|
||||
|
||||
if _operation == "SLICE":
|
||||
newMod.operation = "INTERSECT"
|
||||
@ -819,6 +840,12 @@ class VIEW3D_MT_booltool_menu(Menu):
|
||||
layout.operator(BTool_Inters.bl_idname, text="Intersect", icon="SELECT_INTERSECT")
|
||||
layout.operator(BTool_Slice.bl_idname, text="Slice", icon="SELECT_DIFFERENCE")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.label(text="Options")
|
||||
layout.prop(context.scene, "ArrangeModifier", text="Arrange modifier")
|
||||
layout.prop(context.scene, "ShowExpanded", text="Show expanded")
|
||||
|
||||
if isCanvas(context.active_object):
|
||||
layout.separator()
|
||||
layout.operator(BTool_AllBrushToMesh.bl_idname, icon="MOD_LATTICE", text="Apply All")
|
||||
@ -870,6 +897,11 @@ class VIEW3D_PT_booltool_tools(Panel):
|
||||
col.operator(BTool_Inters.bl_idname, text="Intersect", icon="SELECT_INTERSECT")
|
||||
col.operator(BTool_Slice.bl_idname, text="Slice", icon="SELECT_DIFFERENCE")
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Options")
|
||||
col.prop(context.scene, "ArrangeModifier", text="Arrange modifier")
|
||||
col.prop(context.scene, "ShowExpanded", text="Show expanded")
|
||||
|
||||
# TODO Draw Poly Brush
|
||||
# main.separator()
|
||||
|
||||
@ -1212,6 +1244,16 @@ def register():
|
||||
)
|
||||
bpy.types.VIEW3D_MT_object.append(VIEW3D_BoolTool_Menu)
|
||||
|
||||
bpy.types.Scene.ArrangeModifier = BoolProperty(
|
||||
default=False,
|
||||
description="Sets the newly added modifier under the nearest higher boolean"
|
||||
)
|
||||
|
||||
bpy.types.Scene.ShowExpanded = BoolProperty(
|
||||
default=True,
|
||||
description="Whether the newly added modifier should be expanded or not"
|
||||
)
|
||||
|
||||
wm = bpy.context.window_manager
|
||||
kc = wm.keyconfigs.addon
|
||||
|
||||
@ -1291,10 +1333,12 @@ def unregister():
|
||||
UnRegisterFastT()
|
||||
bpy.types.VIEW3D_MT_object.remove(VIEW3D_BoolTool_Menu)
|
||||
del bpy.types.Scene.BoolHide
|
||||
del bpy.types.Scene.ArrangeModifier
|
||||
del bpy.types.Scene.ShowExpanded
|
||||
|
||||
for cls in classes:
|
||||
bpy.utils.unregister_class(cls)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
register()
|
Loading…
Reference in New Issue
Block a user