mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 14:26:30 +00:00
feat: Convert argument names into prettier looking property names in the IFC Patch Panel
Inspired by #4721
This commit is contained in:
committed by
Dion Moult
parent
6484a529b0
commit
a7152bdef0
@@ -132,7 +132,7 @@ class UpdateIfcPatchArguments(bpy.types.Operator):
|
|||||||
"int": "integer",
|
"int": "integer",
|
||||||
"bool": "boolean",
|
"bool": "boolean",
|
||||||
}[data_type]
|
}[data_type]
|
||||||
new_attr.name = arg_name
|
new_attr.name = self.pretty_arg_name(arg_name)
|
||||||
if new_attr.data_type == "enum":
|
if new_attr.data_type == "enum":
|
||||||
new_attr.enum_items = json.dumps(arg_info.get("enum_items", []))
|
new_attr.enum_items = json.dumps(arg_info.get("enum_items", []))
|
||||||
new_attr.enum_value = arg_info.get("default", new_attr.get_value_default())
|
new_attr.enum_value = arg_info.get("default", new_attr.get_value_default())
|
||||||
@@ -141,6 +141,21 @@ class UpdateIfcPatchArguments(bpy.types.Operator):
|
|||||||
new_attr.set_value(arg_info.get("default", new_attr.get_value_default()))
|
new_attr.set_value(arg_info.get("default", new_attr.get_value_default()))
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
def pretty_arg_name(self, arg_name: str):
|
||||||
|
words = []
|
||||||
|
|
||||||
|
for word in arg_name.split("_"):
|
||||||
|
word = word.strip().capitalize()
|
||||||
|
|
||||||
|
replacements = [("Dir", "Directory"), ("Sql", "SQL")]
|
||||||
|
|
||||||
|
for prev, new in replacements:
|
||||||
|
word = word.replace(prev, new)
|
||||||
|
|
||||||
|
words.append(word)
|
||||||
|
|
||||||
|
return " ".join(words)
|
||||||
|
|
||||||
|
|
||||||
class RunMigratePatch(bpy.types.Operator):
|
class RunMigratePatch(bpy.types.Operator):
|
||||||
bl_idname = "bim.run_migrate_patch"
|
bl_idname = "bim.run_migrate_patch"
|
||||||
|
|||||||
Reference in New Issue
Block a user