mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Tools for handling shared psets #5291
In IFC it's possible for a property set to be assigned to multiple elements and which may lead to confusing behaviour when you edit a pset on one element and other element seems to get edited too. Which makes it worse is that that it is possible that some software is might be doing this unintentionally when exporting IFC (as some sort of optimization as storing 1 is more optimal than n copies of it). So now there are some tools in Bonsai and in IfcOpenShell to handle the shared psest: 1) Indication that property is shared - https://imgur.com/a/9dd3jST (similar to how Blender indicates ID data-block users). You can click on it to "unshare" the pset - a new copy for the pset will be created and it's going to be linked only to the active object. 2) api pset.unshare_pset method that does the same. And util.element.get_elements_using_pset method that encapsulates schema differences and different approaches for occurrences/types. 3) ifcpatch recipe 'UnsharePsets' that's making all property sets in the IFC file to have just 1 element that's using them. You can limit the affected elements by providing query. ifcpatch recipe is also available in Bonsai - https://i.imgur.com/aOCx7HI.png
This commit is contained in:
@@ -422,6 +422,18 @@ def get_properties(
|
||||
return results
|
||||
|
||||
|
||||
def get_elements_using_pset(pset: ifcopenshell.entity_instance) -> set[ifcopenshell.entity_instance]:
|
||||
"""Retrieve the elements (or element types) that are using the provided property set."""
|
||||
is_ifc2x3 = pset.file.schema == "IFC2X3"
|
||||
elements = set()
|
||||
rels = pset.PropertyDefinitionOf if is_ifc2x3 else pset.DefinesOccurrence
|
||||
for rel in rels:
|
||||
elements.update(rel.RelatedObjects)
|
||||
for element_type in pset.DefinesType:
|
||||
elements.add(element_type)
|
||||
return elements
|
||||
|
||||
|
||||
def get_predefined_type(element: ifcopenshell.entity_instance) -> str:
|
||||
"""Retrieves the PrefefinedType attribute of an element.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user