mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Narrow down pset prop template enum items
Depending on whether we're currently editing pset or qto. Before - https://i.imgur.com/w95q7UC.png Now - https://i.imgur.com/0uyHPVC.png
This commit is contained in:
@@ -45,10 +45,12 @@ class PsetTemplatesData:
|
||||
|
||||
# after pset_template_files because it loads IfcStore.pset_template_file
|
||||
cls.data["primary_measure_type"] = cls.primary_measure_type()
|
||||
cls.data["property_template_type"] = cls.property_template_type()
|
||||
cls.data["pset_template"] = cls.pset_template()
|
||||
cls.data["prop_templates"] = cls.prop_templates()
|
||||
|
||||
# after pset_template and prop_templates
|
||||
cls.data["property_template_type"] = cls.property_template_type()
|
||||
|
||||
@classmethod
|
||||
def primary_measure_type(cls) -> list[tuple[str, str, str]]:
|
||||
ifc_file = IfcStore.pset_template_file
|
||||
@@ -66,9 +68,43 @@ class PsetTemplatesData:
|
||||
ifc_file = IfcStore.pset_template_file
|
||||
if not ifc_file:
|
||||
return []
|
||||
pset_data = cls.data["pset_template"]
|
||||
if not pset_data:
|
||||
return []
|
||||
|
||||
# Can't use get_pset_template_type
|
||||
# because need to check both template and prop templates to avoid conflicts during transition.
|
||||
pset_types = set()
|
||||
template_type = pset_data["TemplateType"]
|
||||
if template_type:
|
||||
if template_type.startswith("PSET_"):
|
||||
pset_types.add("PSET")
|
||||
elif template_type.startswith("QTO_"):
|
||||
pset_types.add("QTO")
|
||||
# Can also be 'NOTDEFINED'.
|
||||
|
||||
prop_templates = cls.data["prop_templates"]
|
||||
for prop in prop_templates:
|
||||
prop_template_type = prop["TemplateType"]
|
||||
if prop_template_type:
|
||||
if prop_template_type.startswith("P_"):
|
||||
pset_types.add("PSET")
|
||||
else: # All other values are Q_.
|
||||
pset_types.add("QTO")
|
||||
|
||||
# If mixed typed are used (e.g. during transition), assume type is not specified.
|
||||
pset_type = next(iter(pset_types)) if len(pset_types) == 1 else None
|
||||
|
||||
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema)
|
||||
attribute = schema.declaration_by_name("IfcSimplePropertyTemplate").attributes()[0]
|
||||
return [(i, i, "") for i in ifcopenshell.util.attribute.get_enum_items(attribute)]
|
||||
enum_items = [
|
||||
a
|
||||
for a in ifcopenshell.util.attribute.get_enum_items(attribute)
|
||||
if pset_type is None
|
||||
or (pset_type == "PSET" and a.startswith("P_"))
|
||||
or (pset_type == "QTO" and a.startswith("Q_"))
|
||||
]
|
||||
return [(i, i, "") for i in enum_items]
|
||||
|
||||
@classmethod
|
||||
def pset_template_files(cls):
|
||||
|
||||
@@ -104,6 +104,8 @@ class EnableEditingPsetTemplate(bpy.types.Operator):
|
||||
props.active_pset_template.description = template.Description or ""
|
||||
props.active_pset_template.template_type = template.TemplateType
|
||||
props.active_pset_template.applicable_entity = template.ApplicableEntity or ""
|
||||
# Disable because of the intersecting enums in data.py.
|
||||
props.active_prop_template_id = 0
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -140,6 +142,9 @@ class EnableEditingPropTemplate(bpy.types.Operator):
|
||||
for e in template.Enumerators.EnumerationValues:
|
||||
new = props.active_prop_template.enum_values.add()
|
||||
setattr(new, data_type, e.wrappedValue)
|
||||
|
||||
# Disable because of the intersecting enums in data.py.
|
||||
props.active_pset_template_id = 0
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user