Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brunoperdigao/cc7c263db59ba03c83d8c1f126c64217 to your computer and use it in GitHub Desktop.
Save brunoperdigao/cc7c263db59ba03c83d8c1f126c64217 to your computer and use it in GitHub Desktop.
blenderbim-linked-aggregate-remove-extra-groups.py
import bpy
import blenderbim.tool as tool
import ifcopenshell
from blenderbim.bim.ifc import IfcStore
file = IfcStore.get_file()
for obj in bpy.context.visible_objects:
obj.select_set(False)
element = tool.Ifc.get_entity(obj)
product_groups_name = [
r.RelatingGroup
for r in getattr(element, "HasAssignments", []) or []
if r.is_a("IfcRelAssignsToGroup")
]
for group in product_groups_name:
print(group)
if "Linked Aggregate" in group.Name:
if not element.is_a("IfcElementAssembly"):
ifcopenshell.api.run("group.remove_group", tool.Ifc.get(), group=group)
else:
ifcopenshell.api.run("group.edit_group", tool.Ifc.get(), group=group, attributes={"Name": "BBIM_Linked_Aggregate"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment