add naming helper
convenience function for naming glyphs
This commit is contained in:
parent
da382f5fab
commit
be5f060c98
1 changed files with 94 additions and 0 deletions
94
__init__.py
94
__init__.py
|
@ -564,6 +564,95 @@ class ABC3D_PT_TextManagement(bpy.types.Panel):
|
|||
layout.row().operator(f"{__name__}.remove_text", text="Remove Textobject")
|
||||
|
||||
|
||||
class ABC3D_PG_FontCreation(bpy.types.PropertyGroup):
|
||||
bl_label = "Font Creation Properties"
|
||||
# bl_parent_id = "ABC3D_PG_NamingHelper"
|
||||
# bl_category = "ABC3D"
|
||||
# bl_space_type = "VIEW_3D"
|
||||
# bl_region_type = "UI"
|
||||
# bl_options = {"DEFAULT_CLOSED"}
|
||||
|
||||
def naming_glyph_id_update_callback(self, context):
|
||||
glyph_name = Font.glyph_to_name(self.naming_glyph_id)
|
||||
if self.naming_glyph_full:
|
||||
self.naming_glyph_name = f"{glyph_name}_{self.font_name}_{self.face_name}"
|
||||
else:
|
||||
self.naming_glyph_name = glyph_name
|
||||
|
||||
naming_glyph_id: bpy.props.StringProperty(
|
||||
name="",
|
||||
description="find proper naming for a glyph",
|
||||
default="",
|
||||
maxlen=32,
|
||||
update=naming_glyph_id_update_callback,
|
||||
)
|
||||
|
||||
naming_glyph_name: bpy.props.StringProperty(
|
||||
name="",
|
||||
description="find proper naming for a glyph",
|
||||
default="",
|
||||
maxlen=1024,
|
||||
)
|
||||
|
||||
naming_glyph_full: bpy.props.BoolProperty(
|
||||
default=True,
|
||||
description="Generate full name",
|
||||
update=naming_glyph_id_update_callback,
|
||||
)
|
||||
|
||||
font_name: bpy.props.StringProperty(
|
||||
name="",
|
||||
description="Font name",
|
||||
default="NM_Origin",
|
||||
update=naming_glyph_id_update_callback,
|
||||
)
|
||||
|
||||
face_name: bpy.props.StringProperty(
|
||||
name="",
|
||||
description="FontFace name",
|
||||
default="Tender",
|
||||
update=naming_glyph_id_update_callback,
|
||||
)
|
||||
|
||||
class ABC3D_OT_NamingHelper(bpy.types.Operator):
|
||||
bl_label = "Font Creation Naming Helper Apply To Active Object"
|
||||
bl_idname = f"{__name__}.apply_naming_helper"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
abc3d_font_creation = context.scene.abc3d_font_creation
|
||||
name = abc3d_font_creation.naming_glyph_name
|
||||
context.active_object.name = name
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ABC3D_PT_NamingHelper(bpy.types.Panel):
|
||||
bl_label = "Naming Helper"
|
||||
bl_parent_id = "ABC3D_PT_FontCreation"
|
||||
bl_category = "ABC3D"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
scene = context.scene
|
||||
|
||||
abc3d_font_creation = scene.abc3d_font_creation
|
||||
|
||||
box = layout.box()
|
||||
box.label(text="Glyph Naming Helper")
|
||||
box.row().prop(abc3d_font_creation, "naming_glyph_full")
|
||||
box.label(text="Glyph Character Input")
|
||||
box.row().prop(abc3d_font_creation, "naming_glyph_id")
|
||||
box.label(text="Font name:")
|
||||
box.row().prop(abc3d_font_creation, "font_name")
|
||||
box.label(text="FontFace name:")
|
||||
box.row().prop(abc3d_font_creation, "face_name")
|
||||
box.label(text="Glyph Output Name")
|
||||
box.row().prop(abc3d_font_creation, "naming_glyph_name")
|
||||
box.row().operator(f"{__name__}.apply_naming_helper", text="Apply name to active object")
|
||||
|
||||
class ABC3D_PT_FontCreation(bpy.types.Panel):
|
||||
bl_label = "Font Creation"
|
||||
bl_parent_id = "ABC3D_PT_Panel"
|
||||
|
@ -1517,6 +1606,9 @@ classes = (
|
|||
ABC3D_PT_TextPlacement,
|
||||
ABC3D_PT_TextManagement,
|
||||
ABC3D_PT_FontCreation,
|
||||
ABC3D_PG_FontCreation,
|
||||
ABC3D_OT_NamingHelper,
|
||||
ABC3D_PT_NamingHelper,
|
||||
ABC3D_PT_TextPropertiesPanel,
|
||||
ABC3D_OT_OpenAssetDirectory,
|
||||
ABC3D_OT_LoadInstalledFonts,
|
||||
|
@ -1673,6 +1765,7 @@ def register():
|
|||
addon_updater_ops.make_annotations(cls) # Avoid blender 2.8 warnings.
|
||||
bpy.utils.register_class(cls)
|
||||
bpy.types.Scene.abc3d_data = bpy.props.PointerProperty(type=ABC3D_data)
|
||||
bpy.types.Scene.abc3d_font_creation = bpy.props.PointerProperty(type=ABC3D_PG_FontCreation)
|
||||
# bpy.types.Object.__del__ = lambda self: print(f"Bye {self.name}")
|
||||
|
||||
# autostart if we load a blend file
|
||||
|
@ -1716,6 +1809,7 @@ def unregister():
|
|||
bpy.app.handlers.depsgraph_update_post.remove(on_depsgraph_update)
|
||||
|
||||
del bpy.types.Scene.abc3d_data
|
||||
del bpy.types.Scene.abc3d_font_creation
|
||||
print(f"UNREGISTER {utils.prefix()}")
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue