mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
feat: Parse type "Literal" as enum property in the IFC Patch Panel
This commit is contained in:
committed by
Dion Moult
parent
74fbf29d5f
commit
9ac159e0af
@@ -126,13 +126,17 @@ class UpdateIfcPatchArguments(bpy.types.Operator):
|
||||
if isinstance(data_type, list):
|
||||
data_type = [dt for dt in data_type if dt != "NoneType"][0]
|
||||
new_attr.data_type = {
|
||||
"Literal": "string",
|
||||
"Literal": "enum",
|
||||
"str": "string",
|
||||
"float": "float",
|
||||
"int": "integer",
|
||||
"bool": "boolean",
|
||||
}[data_type]
|
||||
new_attr.name = arg_name
|
||||
if new_attr.data_type == "enum":
|
||||
new_attr.enum_items = json.dumps(arg_info.get("enum_items", []))
|
||||
new_attr.enum_value = arg_info.get("default", new_attr.get_value_default())
|
||||
continue # Temporary workaround, because the Argument class resets the type to "string" when calling `set_value`
|
||||
new_attr.set_value(arg_info.get("default", new_attr.get_value_default()))
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -158,6 +158,9 @@ def _extract_docs(cls, method_name, boilerplate_args):
|
||||
continue
|
||||
if isinstance(type_hint, typing._UnionGenericAlias):
|
||||
inputs[input_name]["type"] = [t.__name__ for t in typing.get_args(type_hint)]
|
||||
elif type_hint.__name__ == "Literal":
|
||||
inputs[input_name]["type"] = "Literal"
|
||||
inputs[input_name]["enum_items"] = list(typing.get_args(type_hint))
|
||||
else:
|
||||
inputs[input_name]["type"] = type_hint.__name__
|
||||
|
||||
|
||||
Reference in New Issue
Block a user