-
-
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.
feat: add the 3 core boolean operators, difference, union, and intersect
- Loading branch information
1 parent
53d7604
commit ca58b0b
Showing
5 changed files
with
81 additions
and
0 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
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,14 @@ | ||
import importlib | ||
from . import vanilla | ||
|
||
|
||
def reload(): | ||
importlib.reload(vanilla) | ||
|
||
|
||
def register(): | ||
vanilla.register() | ||
|
||
|
||
def unregister(): | ||
vanilla.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,50 @@ | ||
import bpy | ||
|
||
|
||
class ND_OT_bool_vanilla(bpy.types.Operator): | ||
bl_idname = "nd.bool_vanilla" | ||
bl_label = "Boolean" | ||
bl_description = "Perform a boolean operation on the selected objects" | ||
bl_options = {'UNDO'} | ||
|
||
|
||
mode: bpy.props.EnumProperty(items=[ | ||
('DIFFERENCE', 'Difference', 'Perform a difference operation'), | ||
('UNION', 'Union', 'Perform a union operation'), | ||
('INTERSECT', 'Intersect', 'Perform an intersect operation'), | ||
], name="Mode", default='DIFFERENCE') | ||
|
||
|
||
@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 | ||
|
||
boolean = context.object.modifiers.new(" — ".join([self.mode.capitalize(), "ND Bool"]), 'BOOLEAN') | ||
boolean.operation = self.mode | ||
boolean.object = reference_obj | ||
boolean.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_vanilla.bl_idname, text=ND_OT_bool_vanilla.bl_label) | ||
|
||
|
||
def register(): | ||
bpy.utils.register_class(ND_OT_bool_vanilla) | ||
bpy.types.VIEW3D_MT_object.append(menu_func) | ||
|
||
|
||
def unregister(): | ||
bpy.utils.unregister_class(ND_OT_bool_vanilla) | ||
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