mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 19:07:57 +00:00
fix get_applicable_entities / get_applicable_types missing schema #6108
This commit is contained in:
@@ -117,7 +117,10 @@ class ObjectPsetsData(Data):
|
||||
if not element:
|
||||
return []
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(
|
||||
element.is_a(), ifcopenshell.util.element.get_predefined_type(element), pset_only=True
|
||||
element.is_a(),
|
||||
ifcopenshell.util.element.get_predefined_type(element),
|
||||
pset_only=True,
|
||||
schema=tool.Ifc.get_schema(),
|
||||
)
|
||||
psetnames = cls.format_pset_enum(psets)
|
||||
assigned_names = ifcopenshell.util.element.get_psets(element, psets_only=True, should_inherit=False).keys()
|
||||
@@ -130,7 +133,10 @@ class ObjectPsetsData(Data):
|
||||
if not element:
|
||||
return []
|
||||
qtos = bonsai.bim.schema.ifc.psetqto.get_applicable(
|
||||
element.is_a(), ifcopenshell.util.element.get_predefined_type(element), qto_only=True
|
||||
element.is_a(),
|
||||
ifcopenshell.util.element.get_predefined_type(element),
|
||||
qto_only=True,
|
||||
schema=tool.Ifc.get_schema(),
|
||||
)
|
||||
return cls.format_pset_enum(qtos)
|
||||
|
||||
@@ -188,7 +194,9 @@ class MaterialPsetsData(Data):
|
||||
if material.ifc_definition_id:
|
||||
material = tool.Ifc.get().by_id(material.ifc_definition_id)
|
||||
category = getattr(material, "Category", None) or None
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(props.material_type, category, pset_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(
|
||||
props.material_type, category, pset_only=True, schema=tool.Ifc.get_schema()
|
||||
)
|
||||
psetnames = cls.format_pset_enum(psets)
|
||||
assigned_names = ifcopenshell.util.element.get_psets(
|
||||
material, psets_only=True, should_inherit=False
|
||||
|
||||
@@ -105,7 +105,7 @@ def get_material_set_pset_names(self, context):
|
||||
if not ifc_class or "Set" not in ifc_class:
|
||||
return []
|
||||
if ifc_class not in psetnames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True, schema=tool.Ifc.get_schema())
|
||||
psetnames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
return psetnames[ifc_class]
|
||||
|
||||
@@ -117,7 +117,7 @@ def get_material_set_item_pset_names(self, context):
|
||||
return []
|
||||
ifc_class = tool.Ifc.get().by_id(ifc_definition_id).is_a()
|
||||
if ifc_class not in psetnames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True, schema=tool.Ifc.get_schema())
|
||||
psetnames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
return psetnames[ifc_class]
|
||||
|
||||
@@ -126,7 +126,7 @@ def get_task_qto_names(self, context):
|
||||
global qtonames
|
||||
ifc_class = "IfcTask"
|
||||
if ifc_class not in qtonames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, qto_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, qto_only=True, schema=tool.Ifc.get_schema())
|
||||
qtonames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
return qtonames[ifc_class]
|
||||
|
||||
@@ -137,7 +137,7 @@ def get_resource_pset_names(self, context):
|
||||
rtprops = context.scene.BIMResourceTreeProperties
|
||||
ifc_class = IfcStore.get_file().by_id(rtprops.resources[rprops.active_resource_index].ifc_definition_id).is_a()
|
||||
if ifc_class not in psetnames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True, schema=tool.Ifc.get_schema())
|
||||
psetnames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
return psetnames[ifc_class]
|
||||
|
||||
@@ -148,7 +148,7 @@ def get_resource_qto_names(self, context):
|
||||
rtprops = context.scene.BIMResourceTreeProperties
|
||||
ifc_class = IfcStore.get_file().by_id(rtprops.resources[rprops.active_resource_index].ifc_definition_id).is_a()
|
||||
if ifc_class not in qtonames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, qto_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, qto_only=True, schema=tool.Ifc.get_schema())
|
||||
qtonames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
return qtonames[ifc_class]
|
||||
|
||||
@@ -157,7 +157,7 @@ def get_group_pset_names(self, context):
|
||||
global psetnames
|
||||
ifc_class = "IfcGroup"
|
||||
if ifc_class not in psetnames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True, schema=tool.Ifc.get_schema())
|
||||
psetnames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
return psetnames[ifc_class]
|
||||
|
||||
@@ -166,7 +166,7 @@ def get_group_qto_names(self, context):
|
||||
global qtonames
|
||||
ifc_class = "IfcGroup"
|
||||
if ifc_class not in qtonames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, qto_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, qto_only=True, schema=tool.Ifc.get_schema())
|
||||
qtonames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
return qtonames[ifc_class]
|
||||
|
||||
@@ -176,7 +176,7 @@ def get_profile_pset_names(self, context):
|
||||
pprops = context.scene.BIMProfileProperties
|
||||
ifc_class = IfcStore.get_file().by_id(pprops.profiles[pprops.active_profile_index].ifc_definition_id).is_a()
|
||||
if ifc_class not in psetnames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True, schema=tool.Ifc.get_schema())
|
||||
psetnames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
return psetnames[ifc_class]
|
||||
|
||||
@@ -185,7 +185,7 @@ def get_work_schedule_pset_names(self, context):
|
||||
global psetnames
|
||||
ifc_class = "IfcWorkSchedule"
|
||||
if ifc_class not in psetnames:
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True)
|
||||
psets = bonsai.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True, schema=tool.Ifc.get_schema())
|
||||
psetnames[ifc_class] = blender_formatted_enum_from_psets(psets)
|
||||
return psetnames[ifc_class]
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class ReassignClass(bpy.types.Operator, tool.Ifc.Operator):
|
||||
root_props = context.scene.BIMRootProperties
|
||||
ifc_product: str = root_props.ifc_product
|
||||
ifc_class: str = root_props.ifc_class
|
||||
type_ifc_class = next(iter(ifcopenshell.util.type.get_applicable_types(ifc_class)), None)
|
||||
type_ifc_class = next(iter(ifcopenshell.util.type.get_applicable_types(ifc_class, self.file.schema)), None)
|
||||
|
||||
predefined_type = root_props.ifc_predefined_type
|
||||
if predefined_type == "USERDEFINED":
|
||||
|
||||
@@ -67,11 +67,12 @@ def refresh_classes(self, context):
|
||||
self.representation_template = "OBJ"
|
||||
self.representation_obj = obj
|
||||
|
||||
ifc_file = tool.Ifc.get()
|
||||
# When switching between ElementType and Element, keep the same class and predefined type if possible
|
||||
if self.ifc_product == "IfcElement":
|
||||
ifc_class = next(iter(ifcopenshell.util.type.get_applicable_entities(old_class)), None)
|
||||
ifc_class = next(iter(ifcopenshell.util.type.get_applicable_entities(old_class, ifc_file.schema)), None)
|
||||
elif self.ifc_product == "IfcElementType":
|
||||
ifc_class = next(iter(ifcopenshell.util.type.get_applicable_types(old_class)), None)
|
||||
ifc_class = next(iter(ifcopenshell.util.type.get_applicable_types(old_class, ifc_file.schema)), None)
|
||||
else:
|
||||
return
|
||||
if ifc_class:
|
||||
|
||||
@@ -81,7 +81,9 @@ class Pset(bonsai.core.tool.Pset):
|
||||
predefined_type = ifcopenshell.util.element.get_predefined_type(element)
|
||||
return bool(
|
||||
pset_name
|
||||
in bonsai.bim.schema.ifc.psetqto.get_applicable_names(element.is_a(), predefined_type, pset_only=True)
|
||||
in bonsai.bim.schema.ifc.psetqto.get_applicable_names(
|
||||
element.is_a(), predefined_type, pset_only=True, schema=tool.Ifc.get_schema()
|
||||
)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user