mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
Add min 0 value to IFC props in UI
Basically it won't allow setting values below 0 by accident (especially important for representation item props as it may lead to a crash). 1) IfcPositiveLengthMeasure will affect bunch of props like Depth in IfcExtrudedAreaSolid. 2) IfcNonNegativeLengthMeasure will affect MaterialLayer and some profiles attributes.
This commit is contained in:
@@ -176,18 +176,23 @@ def import_attribute(
|
|||||||
if data[new.name]:
|
if data[new.name]:
|
||||||
new.enum_value = data[new.name]
|
new.enum_value = data[new.name]
|
||||||
add_attribute_description(new, data)
|
add_attribute_description(new, data)
|
||||||
add_attribute_min_max(new)
|
add_attribute_min_max(attribute, new)
|
||||||
|
|
||||||
|
|
||||||
ATTRIBUTE_MIN_MAX_CONSTRAINTS = {"IfcMaterialLayer": {"Priority": {"value_min": 0, "value_max": 100}}}
|
ATTRIBUTE_MIN_MAX_CONSTRAINTS = {"IfcMaterialLayer": {"Priority": {"value_min": 0, "value_max": 100}}}
|
||||||
|
|
||||||
|
|
||||||
def add_attribute_min_max(attribute_blender: bonsai.bim.prop.Attribute) -> None:
|
def add_attribute_min_max(attribute: W.attribute, attribute_blender: bonsai.bim.prop.Attribute) -> None:
|
||||||
if attribute_blender.ifc_class in ATTRIBUTE_MIN_MAX_CONSTRAINTS:
|
if attribute_blender.ifc_class in ATTRIBUTE_MIN_MAX_CONSTRAINTS:
|
||||||
constraints = ATTRIBUTE_MIN_MAX_CONSTRAINTS[attribute_blender.ifc_class].get(attribute_blender.name, {})
|
constraints = ATTRIBUTE_MIN_MAX_CONSTRAINTS[attribute_blender.ifc_class].get(attribute_blender.name, {})
|
||||||
for constraint, value in constraints.items():
|
for constraint, value in constraints.items():
|
||||||
setattr(attribute_blender, constraint, value)
|
setattr(attribute_blender, constraint, value)
|
||||||
setattr(attribute_blender, constraint + "_constraint", True)
|
setattr(attribute_blender, constraint + "_constraint", True)
|
||||||
|
attribute_type = attribute.type_of_attribute()
|
||||||
|
|
||||||
|
if attribute_type._is("IfcPositiveLengthMeasure") or attribute_type._is("IfcNonNegativeLengthMeasure"):
|
||||||
|
attribute_blender.value_min = 0.0
|
||||||
|
attribute_blender.value_min_constraint = True
|
||||||
|
|
||||||
|
|
||||||
def add_attribute_enum_items_descriptions(
|
def add_attribute_enum_items_descriptions(
|
||||||
|
|||||||
Reference in New Issue
Block a user