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:
Andrej730
2024-11-15 14:57:48 +05:00
parent de17736002
commit 9f372017bc
@@ -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: