Skip to content

Commit

Permalink
feat: split blank_sketch into single_vertex and make_manifold operators
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Apr 17, 2022
1 parent aae7e91 commit 08f6efe
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 4 deletions.
13 changes: 13 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class NDPreferences(AddonPreferences):
default=False,
)

enable_deprecated_features: BoolProperty(
name="Compatibility Mode",
default=False,
)

utils_collection_name: StringProperty(
name="Utils Collection Name",
default="Utils",
Expand Down Expand Up @@ -107,6 +112,14 @@ def draw_general(self, box):
row = column.row()
row.prop(self, "utils_collection_name")

box = box.box()
column = box.column(align=True)
row = column.row()
row.label(text="Enable deprecated features for short term backwards compatibility", icon="ERROR")
column = box.column(align=True)
row = column.row()
row.prop(self, "enable_deprecated_features")


def draw_ui(self, box):
column = box.column(align=True)
Expand Down
7 changes: 6 additions & 1 deletion interface/main_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ def draw(self, context):
layout.separator()

layout.operator_context = 'INVOKE_DEFAULT'
layout.operator("nd.single_vertex", icon='DOT')
layout.operator("nd.make_manifold", icon='OUTLINER_DATA_SURFACE')
layout.operator("nd.view_align", icon='ORIENTATION_VIEW')
layout.operator("nd.geo_lift", icon='FACESEL')
layout.operator("nd.blank_sketch", icon='GREASEPENCIL')

if lib.preferences.get_preferences().enable_deprecated_features:
layout.operator("nd.blank_sketch", icon='GREASEPENCIL')

layout.separator()
layout.menu("ND_MT_boolean_menu", icon='MOD_BOOLEAN')
layout.menu("ND_MT_bevel_menu", icon='MOD_BEVEL')
Expand Down
15 changes: 12 additions & 3 deletions interface/main_ui_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,24 @@ def draw(self, context):

row = column.row(align=True)
row.scale_y = 1.2
row.operator("nd.geo_lift", icon='FACESEL')
row.operator("nd.single_vertex", icon='DOT')

row = column.row(align=True)
row.scale_y = 1.2
row.operator("nd.view_align", icon='ORIENTATION_VIEW')
row.operator("nd.make_manifold", icon='OUTLINER_DATA_SURFACE')

row = column.row(align=True)
row.scale_y = 1.2
row.operator("nd.blank_sketch", icon='GREASEPENCIL')
row.operator("nd.geo_lift", icon='FACESEL')

row = column.row(align=True)
row.scale_y = 1.2
row.operator("nd.view_align", icon='ORIENTATION_VIEW')

if lib.preferences.get_preferences().enable_deprecated_features:
row = column.row(align=True)
row.scale_y = 1.2
row.operator("nd.blank_sketch", icon='GREASEPENCIL')

box = layout.box()
box.label(text="Power Mods", icon='MODIFIER')
Expand Down
8 changes: 8 additions & 0 deletions sketching/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@
from . import blank_sketch
from . import view_align
from . import geo_lift
from . import single_vertex
from . import make_manifold


def reload():
importlib.reload(blank_sketch)
importlib.reload(view_align)
importlib.reload(geo_lift)
importlib.reload(single_vertex)
importlib.reload(make_manifold)


def register():
blank_sketch.register()
view_align.register()
geo_lift.register()
single_vertex.register()
make_manifold.register()


def unregister():
blank_sketch.unregister()
view_align.unregister()
geo_lift.unregister()
single_vertex.unregister()
make_manifold.unregister()


37 changes: 37 additions & 0 deletions sketching/make_manifold.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import bpy
import bmesh


class ND_OT_make_manifold(bpy.types.Operator):
bl_idname = "nd.make_manifold"
bl_label = "Make Manifold"
bl_description = "Attempts to turn the current sketch into a manifold polygon"
bl_options = {'UNDO'}


def execute(self, context):
bpy.ops.object.mode_set_with_submode(mode='EDIT', mesh_select_mode={'VERT'})
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.remove_doubles(threshold=0.0001)
bpy.ops.mesh.edge_face_add()

return {'RUNNING_MODAL'}


@classmethod
def poll(cls, context):
return context.mode == 'EDIT_MESH'


def menu_func(self, context):
self.layout.operator(ND_OT_make_manifold.bl_idname, text=ND_OT_make_manifold.bl_label)


def register():
bpy.utils.register_class(ND_OT_make_manifold)
bpy.types.VIEW3D_MT_object.append(menu_func)


def unregister():
bpy.utils.unregister_class(ND_OT_make_manifold)
bpy.types.VIEW3D_MT_object.remove(menu_func)
41 changes: 41 additions & 0 deletions sketching/single_vertex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import bpy
from .. lib.objects import add_single_vertex_object, align_object_to_3d_cursor


class ND_OT_single_vertex(bpy.types.Operator):
bl_idname = "nd.single_vertex"
bl_label = "Single Vertex"
bl_description = "Creates a single vertex object at the 3D cursor"
bl_options = {'UNDO'}


def execute(self, context):
add_single_vertex_object(self, context, "Sketch")
align_object_to_3d_cursor(self, context)
self.start_sketch_editing(context)

return {'FINISHED'}


@classmethod
def poll(cls, context):
return context.mode == 'OBJECT'


def start_sketch_editing(self, context):
bpy.ops.object.mode_set_with_submode(mode='EDIT', mesh_select_mode={'VERT'})
bpy.ops.mesh.select_all(action='SELECT')


def menu_func(self, context):
self.layout.operator(ND_OT_single_vertex.bl_idname, text=ND_OT_single_vertex.bl_label)


def register():
bpy.utils.register_class(ND_OT_single_vertex)
bpy.types.VIEW3D_MT_object.append(menu_func)


def unregister():
bpy.utils.unregister_class(ND_OT_single_vertex)
bpy.types.VIEW3D_MT_object.remove(menu_func)

0 comments on commit 08f6efe

Please sign in to comment.