autodetect names earlier
this makes it obvious to the user if autodetect works
This commit is contained in:
parent
9252985405
commit
fc9b1b65b0
1 changed files with 18 additions and 8 deletions
26
__init__.py
26
__init__.py
|
@ -1248,6 +1248,18 @@ class ABC3D_OT_CreateFontFromObjects(bpy.types.Operator):
|
|||
wm = context.window_manager
|
||||
return wm.invoke_props_dialog(self)
|
||||
|
||||
def do_autodetect_names(self, name: str):
|
||||
ifxsplit = name.split("_")
|
||||
if len(ifxsplit) < 4:
|
||||
print(f"name could not be autodetected {name}")
|
||||
print("split:")
|
||||
print(ifxsplit)
|
||||
return self.font_name, self.face_name, self.import_infix
|
||||
detected_font_name = f"{ifxsplit[1]}_{ifxsplit[2]}"
|
||||
detected_face_name = ifxsplit[3]
|
||||
detected_import_infix = f"{ifxsplit[1]}_{ifxsplit[2]}_{ifxsplit[3]}"
|
||||
return detected_font_name, detected_face_name, detected_import_infix
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
if len(context.selected_objects) == 0:
|
||||
|
@ -1255,7 +1267,11 @@ class ABC3D_OT_CreateFontFromObjects(bpy.types.Operator):
|
|||
layout.row().label(text="Please select your glyphs first.", icon="INFO")
|
||||
else:
|
||||
row = layout.row()
|
||||
row.prop(self, 'autodetect_names')
|
||||
row.prop(self, "autodetect_names")
|
||||
first_object_name = context.selected_objects[-1].name
|
||||
self.font_name, self.face_name, self.import_infix = (
|
||||
self.do_autodetect_names(first_object_name)
|
||||
)
|
||||
if self.autodetect_names:
|
||||
scale_y = 0.5
|
||||
row = layout.row()
|
||||
|
@ -1342,13 +1358,7 @@ class ABC3D_OT_CreateFontFromObjects(bpy.types.Operator):
|
|||
print(f"processing {o.name}")
|
||||
process_object = True
|
||||
if self.autodetect_names:
|
||||
ifxsplit = o.name.split('_')
|
||||
if len(ifxsplit) < 4:
|
||||
print(
|
||||
f"whoops name could not be autodetected {o.name}")
|
||||
continue
|
||||
font_name = f"{ifxsplit[1]}_{ifxsplit[2]}"
|
||||
face_name = ifxsplit[3]
|
||||
font_name, face_name, input_infix = self.do_autodetect_names(o.name)
|
||||
|
||||
if butils.is_mesh(o) and not butils.is_metrics_object(o):
|
||||
uc = o.users_collection
|
||||
|
|
Loading…
Add table
Reference in a new issue