Improve ifc patch arguments User Experience (#1655)

* Add description field to Attribute Container

* Add helper function to extract IFCPatch arguments

* Add Operator to populate Attributes with IFCPatch arguments

* Support int, float, bool and improve UX/UI

* Move all reflection logic inside helper module

* Improve UI

* Correctly unpack arguments when Patching IFC

* Refactor Attribute class to provide agnostic value access

* Take advantage of Attribute agnosticity refactor

* Use regular json if no docstring when Patching

* centralize docstring extraction in UI module

* Revert "centralize docstring extraction in UI module"

This reverts commit e7a63d2a0b.

* Place Patch description in recipe enum field

* Minor fixes

* Minor fixes

* Remove description field from Attribute

* Auto-update IFC Patch args on recipe change
This commit is contained in:
Gorgious56
2021-08-16 00:16:51 +02:00
committed by GitHub
parent d22c11c200
commit 296bf0387d
20 changed files with 247 additions and 325 deletions
@@ -136,31 +136,11 @@ class EnablePsetEditing(bpy.types.Operator):
prop = Data.properties[prop_id]
value = prop["NominalValue"]
if isinstance(value, str):
data_type = "string"
elif isinstance(value, float):
data_type = "float"
elif isinstance(value, bool):
data_type = "boolean"
elif isinstance(value, int):
data_type = "integer"
else:
data_type = "string"
value = str(value)
new = self.props.properties.add()
new.set_value(value)
new.name = prop["Name"]
new.is_null = prop["NominalValue"] is None
new.data_type = data_type
if data_type == "string":
new.string_value = "" if new.is_null else value
elif data_type == "integer":
new.int_value = 0 if new.is_null else value
elif data_type == "float":
new.float_value = 0.0 if new.is_null else value
elif data_type == "boolean":
new.bool_value = False if new.is_null else value
new.is_null = value is None
new.set_value(new.get_value_default() if new.is_null else value)
class DisablePsetEditing(bpy.types.Operator):
@@ -200,18 +180,7 @@ class EditPset(bpy.types.Operator):
else:
data = Data.psets if pset_id in Data.psets else Data.qtos
for prop in props.properties:
if prop.is_null:
properties[prop.name] = None
elif prop.data_type == "string":
properties[prop.name] = prop.string_value
elif prop.data_type == "boolean":
properties[prop.name] = prop.bool_value
elif prop.data_type == "integer":
properties[prop.name] = prop.int_value
elif prop.data_type == "float":
properties[prop.name] = prop.float_value
elif prop.data_type == "enum":
properties[prop.name] = prop.enum_value
properties[prop.name] = prop.get_value()
if pset_id in Data.psets:
ifcopenshell.api.run(