-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add name_sync operator and new ND Utils UI panel
- Loading branch information
1 parent
52e73ed
commit dfcc13d
Showing
5 changed files
with
84 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 |
---|---|---|
@@ -1,18 +1,22 @@ | ||
import importlib | ||
from . import main_ui_panel | ||
from . import utils_ui_panel | ||
from . import main_menu | ||
|
||
|
||
def reload(): | ||
importlib.reload(main_ui_panel) | ||
importlib.reload(utils_ui_panel) | ||
importlib.reload(main_menu) | ||
|
||
|
||
def register(): | ||
main_ui_panel.register() | ||
utils_ui_panel.register() | ||
main_menu.register() | ||
|
||
|
||
def unregister(): | ||
main_ui_panel.unregister() | ||
utils_ui_panel.unregister() | ||
main_menu.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,30 @@ | ||
import bpy | ||
from .. import bl_info | ||
|
||
|
||
class ND_PT_utils_ui_panel(bpy.types.Panel): | ||
bl_label = "ND Utils v%s" % ('.'.join([str(v) for v in bl_info['version']])) | ||
bl_idname = "ND_PT_utils_ui_panel" | ||
bl_space_type = 'VIEW_3D' | ||
bl_region_type = 'UI' | ||
bl_category = "HugeMenace" | ||
|
||
|
||
def draw(self, context): | ||
layout = self.layout | ||
|
||
box = layout.box() | ||
box.label(text="Scene Management", icon='SCENE_DATA') | ||
column = box.column() | ||
|
||
row = column.row(align=True) | ||
row.scale_y = 1.2 | ||
row.operator("nd.name_sync", icon='FILE_REFRESH') | ||
|
||
|
||
def register(): | ||
bpy.utils.register_class(ND_PT_utils_ui_panel) | ||
|
||
|
||
def unregister(): | ||
bpy.utils.unregister_class(ND_PT_utils_ui_panel) |
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 name_sync | ||
|
||
|
||
def reload(): | ||
importlib.reload(name_sync) | ||
|
||
|
||
def register(): | ||
name_sync.register() | ||
|
||
|
||
def unregister(): | ||
name_sync.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,34 @@ | ||
import bpy | ||
|
||
|
||
class ND_OT_name_sync(bpy.types.Operator): | ||
bl_idname = "nd.name_sync" | ||
bl_label = "Name Sync" | ||
bl_description = "Updates all data names to match their corresponding object names" | ||
bl_options = {'UNDO'} | ||
|
||
|
||
@classmethod | ||
def poll(cls, context): | ||
return len(context.selected_objects) == 1 | ||
|
||
|
||
def execute(self, context): | ||
for obj in context.selected_objects: | ||
obj.data.name = obj.name | ||
|
||
return {'FINISHED'} | ||
|
||
|
||
def menu_func(self, context): | ||
self.layout.operator(ND_OT_name_sync.bl_idname, text=ND_OT_name_sync.bl_label) | ||
|
||
|
||
def register(): | ||
bpy.utils.register_class(ND_OT_name_sync) | ||
bpy.types.VIEW3D_MT_object.append(menu_func) | ||
|
||
|
||
def unregister(): | ||
bpy.utils.unregister_class(ND_OT_name_sync) | ||
bpy.types.VIEW3D_MT_object.remove(menu_func) |