-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a85cd2
commit 722dd8d
Showing
6 changed files
with
97 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import importlib | ||
from . import vanilla | ||
from . import boolean_slice | ||
|
||
|
||
def reload(): | ||
importlib.reload(vanilla) | ||
importlib.reload(boolean_slice) | ||
|
||
|
||
def register(): | ||
vanilla.register() | ||
boolean_slice.register() | ||
|
||
|
||
def unregister(): | ||
vanilla.unregister() | ||
boolean_slice.unregister() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import bpy | ||
|
||
|
||
class ND_OT_bool_slice(bpy.types.Operator): | ||
bl_idname = "nd.bool_slice" | ||
bl_label = "Slice" | ||
bl_description = "Perform a boolean operation on the selected objects" | ||
bl_options = {'UNDO'} | ||
|
||
|
||
@classmethod | ||
def poll(cls, context): | ||
if context.mode == 'OBJECT': | ||
return len(context.selected_objects) == 2 | ||
|
||
|
||
def execute(self, context): | ||
a, b = context.selected_objects | ||
reference_obj = a if a.name != context.object.name else b | ||
|
||
difference_obj = context.object | ||
|
||
intersecting_obj = context.object.copy() | ||
intersecting_obj.data = context.object.data.copy() | ||
intersecting_obj.animation_data_clear() | ||
context.collection.objects.link(intersecting_obj) | ||
|
||
boolean_diff = difference_obj.modifiers.new("Difference — ND Bool", 'BOOLEAN') | ||
boolean_diff.operation = 'DIFFERENCE' | ||
boolean_diff.object = reference_obj | ||
boolean_diff.solver = 'EXACT' | ||
|
||
boolean_isect = intersecting_obj.modifiers.new("Intersection — ND Bool", 'BOOLEAN') | ||
boolean_isect.operation = 'INTERSECT' | ||
boolean_isect.object = reference_obj | ||
boolean_isect.solver = 'EXACT' | ||
|
||
reference_obj.display_type = 'WIRE' | ||
reference_obj.hide_render = True | ||
|
||
return {'FINISHED'} | ||
|
||
|
||
def menu_func(self, context): | ||
self.layout.operator(ND_OT_bool_slice.bl_idname, text=ND_OT_bool_slice.bl_label) | ||
|
||
|
||
def register(): | ||
bpy.utils.register_class(ND_OT_bool_slice) | ||
bpy.types.VIEW3D_MT_object.append(menu_func) | ||
|
||
|
||
def unregister(): | ||
bpy.utils.unregister_class(ND_OT_bool_slice) | ||
bpy.types.VIEW3D_MT_object.remove(menu_func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import bpy | ||
from .. import bl_info | ||
|
||
|
||
class ND_MT_boolean_menu(bpy.types.Menu): | ||
bl_label = "Booleans" | ||
bl_idname = "ND_MT_boolean_menu" | ||
|
||
|
||
def draw(self, context): | ||
layout = self.layout | ||
layout.operator_context = 'INVOKE_DEFAULT' | ||
layout.operator("nd.bool_vanilla", text="Difference", icon='MOD_BOOLEAN').mode = 'DIFFERENCE' | ||
layout.operator("nd.bool_vanilla", text="Union", icon='MOD_BOOLEAN').mode = 'UNION' | ||
layout.operator("nd.bool_vanilla", text="Intersect", icon='MOD_BOOLEAN').mode = 'INTERSECT' | ||
layout.operator("nd.bool_slice", icon='MOD_BOOLEAN') | ||
|
||
|
||
def draw_item(self, context): | ||
layout = self.layout | ||
layout.menu(ND_MT_boolean_menu.bl_idname) | ||
|
||
|
||
def register(): | ||
bpy.utils.register_class(ND_MT_boolean_menu) | ||
bpy.types.INFO_HT_header.append(draw_item) | ||
|
||
|
||
def unregister(): | ||
bpy.utils.unregister_class(ND_MT_boolean_menu) | ||
bpy.types.INFO_HT_header.remove(draw_item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters