Created
November 22, 2023 00:46
-
-
Save brunoperdigao/cc7c263db59ba03c83d8c1f126c64217 to your computer and use it in GitHub Desktop.
blenderbim-linked-aggregate-remove-extra-groups.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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