See #3069. More cleanup moving away from collection names and assumed single collections.

This commit is contained in:
Dion Moult
2023-06-01 17:39:36 +10:00
parent 7cd7ad1281
commit 7020caf682
5 changed files with 12 additions and 20 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ name = "bcf-client"
description = "BCF-XML file handler."
readme = "README.md"
requires-python = ">=3.8"
keywords = ["IFC", "BCF", "BIM", "eingineering"]
keywords = ["IFC", "BCF", "BIM"]
dependencies = [
"xsdata",
"numpy",
@@ -43,7 +43,7 @@ def sync_name(usecase_path, ifc_file, settings):
style = tool.Style.get_style(obj)
if style and style != element:
style.Name = new_name
collection = bpy.data.collections.get(obj.name)
collection = obj.BIMObjectProperties.collection
if collection:
collection.name = new_name
obj.name = new_name
+5 -1
View File
@@ -62,7 +62,11 @@ class Collector(blenderbim.core.tool.Collector):
if not parent_collection:
return
parent = tool.Ifc.get_entity(parent_collection.BIMCollectionProperties.obj)
parent_obj = parent_collection.BIMCollectionProperties.obj
if not parent_obj:
return
parent = tool.Ifc.get_entity(parent_obj)
if parent:
# This is lazy, but works. One of these will succeed, the other will fail silently.
blenderbim.core.spatial.assign_container(
+5 -4
View File
@@ -74,17 +74,18 @@ class Geometry(blenderbim.core.tool.Geometry):
if element.is_a("IfcRelSpaceBoundary"):
ifcopenshell.api.run("boundary.remove_boundary", tool.Ifc.get(), boundary=element)
return bpy.data.objects.remove(obj)
if obj.users_collection and obj.users_collection[0].name == obj.name:
collection = obj.BIMObjectProperties.collection
if collection:
parent = ifcopenshell.util.element.get_aggregate(element)
if not parent:
parent = ifcopenshell.util.element.get_container(element)
if parent:
parent_obj = tool.Ifc.get_object(parent)
if parent_obj:
parent_collection = bpy.data.collections.get(parent_obj.name)
for child in obj.users_collection[0].children:
parent_collection = parent_obj.BIMObjectProperties.collection
for child in collection.children:
parent_collection.children.link(child)
bpy.data.collections.remove(obj.users_collection[0])
bpy.data.collections.remove(collection)
if getattr(element, "FillsVoids", None):
bpy.ops.bim.remove_filling(filling=element.id())
-13
View File
@@ -161,17 +161,4 @@ class Root(blenderbim.core.tool.Root):
if "/" in name and name.split("/")[0][0:3] == "Ifc":
name = "/".join(name.split("/")[1:])
name = "{}/{}".format(element.is_a(), name)
# By default, if another object with the same name exists, the existing
# object becomes Foo.001 and the new object becomes Foo. However, if we
# also had a collection that was named Foo, it wouldn't change to
# Foo.001. This code ensures existing objects and their corresponding
# collections stay in sync.
existing_obj = bpy.data.objects.get(name)
existing_collection = bpy.data.collections.get(name)
obj.name = name
if existing_obj:
if existing_collection:
existing_collection.name = existing_obj.name