Drawing collection hierarchy is now auto fixed if shuffled around manually. See #1153.

This commit is contained in:
Dion Moult
2022-01-29 21:08:22 +11:00
parent 677a9d715c
commit 46e1a46dd2
2 changed files with 26 additions and 0 deletions
@@ -122,6 +122,12 @@ class Collector(blenderbim.core.tool.Collector):
return axes_col[0]
return bpy.data.collections.new(axes)
if element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
for rel in element.HasAssignments or []:
if rel.is_a("IfcRelAssignsToGroup"):
name = "IfcGroup/" + rel.RelatingGroup.Name
return bpy.data.collections.get(name, bpy.data.collections.new(name))
if getattr(element, "IsDecomposedBy", None):
return bpy.data.collections.get(obj.name, bpy.data.collections.new(obj.name))
@@ -157,6 +163,14 @@ class Collector(blenderbim.core.tool.Collector):
if grid_obj:
return bpy.data.collections.get(grid_obj.name)
if element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
collection = bpy.data.collections.get("Views")
if not collection:
collection = bpy.data.collections.new("Views")
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
project_obj.users_collection[0].children.link(collection)
return collection
aggregate = ifcopenshell.util.element.get_aggregate(element)
if aggregate:
aggregate_obj = tool.Ifc.get_object(aggregate)
@@ -215,6 +215,18 @@ class TestAssign(NewFile):
assert axis_obj.users_collection[0].name == "UAxes"
assert bpy.data.collections.get("IfcGrid/Name").children.get("UAxes")
def test_in_decomposition_mode_drawings_are_placed_in_a_group_in_a_views_collection(self):
bpy.ops.bim.create_project()
element_obj = bpy.data.objects.new("IfcAnnotation/Name", None)
element = tool.Ifc.get().createIfcAnnotation(ObjectType="DRAWING")
tool.Ifc.link(element, element_obj)
group = ifcopenshell.api.run("group.add_group", tool.Ifc.get())
ifcopenshell.api.run("group.assign_group", tool.Ifc.get(), product=element, group=group)
subject.assign(element_obj)
assert element_obj.users_collection[0].name == "IfcGroup/Unnamed"
assert bpy.data.collections.get("Views").children.get("IfcGroup/Unnamed")
assert bpy.data.collections.get("IfcProject/My Project").children.get("Views")
class TestSync(NewFile):
def test_in_decomposition_mode_elements_can_be_in_spatial_containers(self):