mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
ifcgit: improve colourise to find products via geometry and property changes
Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -388,20 +388,43 @@ class IfcGit:
|
|||||||
model = tool.Ifc.get()
|
model = tool.Ifc.get()
|
||||||
modified_step_ids = {"modified": set()}
|
modified_step_ids = {"modified": set()}
|
||||||
|
|
||||||
for step_id in step_ids["modified"] | step_ids["added"]:
|
def collect(entity, depth=0):
|
||||||
try:
|
if depth > 2:
|
||||||
entity = model.by_id(step_id)
|
return
|
||||||
except:
|
if entity.is_a("IfcProduct"):
|
||||||
continue
|
modified_step_ids["modified"].add(entity.id())
|
||||||
if entity.is_a("IfcProductDefinitionShape"):
|
elif entity.is_a("IfcProductDefinitionShape"):
|
||||||
for product in entity.ShapeOfProduct:
|
for product in entity.ShapeOfProduct:
|
||||||
modified_step_ids["modified"].add(product.id())
|
modified_step_ids["modified"].add(product.id())
|
||||||
elif entity.is_a("IfcObjectPlacement"):
|
elif entity.is_a("IfcObjectPlacement"):
|
||||||
for product in entity.PlacesObject:
|
for product in entity.PlacesObject:
|
||||||
modified_step_ids["modified"].add(product.id())
|
modified_step_ids["modified"].add(product.id())
|
||||||
elif entity.is_a("IfcTypeProduct") and entity.Types:
|
elif entity.is_a("IfcTypeProduct"):
|
||||||
for related_object in entity.Types[0].RelatedObjects:
|
for rel in entity.Types:
|
||||||
modified_step_ids["modified"].add(related_object.id())
|
for obj in rel.RelatedObjects:
|
||||||
|
modified_step_ids["modified"].add(obj.id())
|
||||||
|
elif entity.is_a("IfcShapeRepresentation"):
|
||||||
|
for prod_rep in entity.OfProductRepresentation:
|
||||||
|
for product in prod_rep.ShapeOfProduct:
|
||||||
|
modified_step_ids["modified"].add(product.id())
|
||||||
|
elif entity.is_a("IfcRepresentationItem"):
|
||||||
|
for referencing in model.get_inverse(entity):
|
||||||
|
if referencing.is_a("IfcShapeRepresentation"):
|
||||||
|
collect(referencing, depth + 1)
|
||||||
|
elif entity.is_a("IfcPropertySet"):
|
||||||
|
for rel in entity.DefinesOccurrence:
|
||||||
|
for obj in rel.RelatedObjects:
|
||||||
|
modified_step_ids["modified"].add(obj.id())
|
||||||
|
elif entity.is_a("IfcProperty"):
|
||||||
|
for pset in entity.PartOfPset:
|
||||||
|
collect(pset, depth + 1)
|
||||||
|
|
||||||
|
for step_id in step_ids["modified"] | step_ids["added"]:
|
||||||
|
try:
|
||||||
|
entity = model.by_id(step_id)
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
collect(entity)
|
||||||
|
|
||||||
return modified_step_ids
|
return modified_step_ids
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user