mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Bonsai - document qset prop type inference from prop name
In "add new prop" operator description - https://i.imgur.com/ODeMDL8.png
This commit is contained in:
@@ -447,6 +447,33 @@ class AddProposedProp(bpy.types.Operator):
|
||||
prop_name: bpy.props.StringProperty()
|
||||
prop_value: bpy.props.StringProperty()
|
||||
|
||||
@classmethod
|
||||
def description(cls, context, properties):
|
||||
description = "Add proposed property to the custom property set.\n\n"
|
||||
props = tool.Pset.get_pset_props(properties.obj, properties.obj_type)
|
||||
if props.active_pset_type == "PSET":
|
||||
description += (
|
||||
"Property type will be deduced from the provided value. Possible types:\n"
|
||||
"- provide an integer or a float to create integer/real property\n"
|
||||
"- 'true', 'false' to add a boolean property\n"
|
||||
"- 'null' or '' (empty value) to add a null property\n"
|
||||
"- any other value will be added as a string property"
|
||||
)
|
||||
else:
|
||||
from ifcopenshell.api.pset.edit_qto import FLOAT_TYPE_KEYWORDS
|
||||
|
||||
description += (
|
||||
"Property type will be deduced from the provided value and property name. Possible types:\n"
|
||||
"- Integer values - Count type\n"
|
||||
"- Float values - will try to match one of the keywords below in prop name, "
|
||||
"otherwise will default to Length type\n\n"
|
||||
"Types and their keywords:\n"
|
||||
)
|
||||
for prop_type, keywords in FLOAT_TYPE_KEYWORDS:
|
||||
description += f"- {prop_type} - {', '.join(keywords)}\n"
|
||||
description = description.rstrip() # Strip last newline.
|
||||
return description
|
||||
|
||||
def execute(self, context):
|
||||
res = core.add_proposed_prop(tool.Pset, self.obj, self.obj_type, self.prop_name, self.prop_value)
|
||||
if res:
|
||||
|
||||
Reference in New Issue
Block a user