mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
See #3069. More cleanup moving away from collection names and assumed single collections.
This commit is contained in:
@@ -11,7 +11,7 @@ name = "bcf-client"
|
|||||||
description = "BCF-XML file handler."
|
description = "BCF-XML file handler."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
keywords = ["IFC", "BCF", "BIM", "eingineering"]
|
keywords = ["IFC", "BCF", "BIM"]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"xsdata",
|
"xsdata",
|
||||||
"numpy",
|
"numpy",
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ def sync_name(usecase_path, ifc_file, settings):
|
|||||||
style = tool.Style.get_style(obj)
|
style = tool.Style.get_style(obj)
|
||||||
if style and style != element:
|
if style and style != element:
|
||||||
style.Name = new_name
|
style.Name = new_name
|
||||||
collection = bpy.data.collections.get(obj.name)
|
collection = obj.BIMObjectProperties.collection
|
||||||
if collection:
|
if collection:
|
||||||
collection.name = new_name
|
collection.name = new_name
|
||||||
obj.name = new_name
|
obj.name = new_name
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ class Collector(blenderbim.core.tool.Collector):
|
|||||||
if not parent_collection:
|
if not parent_collection:
|
||||||
return
|
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:
|
if parent:
|
||||||
# This is lazy, but works. One of these will succeed, the other will fail silently.
|
# This is lazy, but works. One of these will succeed, the other will fail silently.
|
||||||
blenderbim.core.spatial.assign_container(
|
blenderbim.core.spatial.assign_container(
|
||||||
|
|||||||
@@ -74,17 +74,18 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
if element.is_a("IfcRelSpaceBoundary"):
|
if element.is_a("IfcRelSpaceBoundary"):
|
||||||
ifcopenshell.api.run("boundary.remove_boundary", tool.Ifc.get(), boundary=element)
|
ifcopenshell.api.run("boundary.remove_boundary", tool.Ifc.get(), boundary=element)
|
||||||
return bpy.data.objects.remove(obj)
|
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)
|
parent = ifcopenshell.util.element.get_aggregate(element)
|
||||||
if not parent:
|
if not parent:
|
||||||
parent = ifcopenshell.util.element.get_container(element)
|
parent = ifcopenshell.util.element.get_container(element)
|
||||||
if parent:
|
if parent:
|
||||||
parent_obj = tool.Ifc.get_object(parent)
|
parent_obj = tool.Ifc.get_object(parent)
|
||||||
if parent_obj:
|
if parent_obj:
|
||||||
parent_collection = bpy.data.collections.get(parent_obj.name)
|
parent_collection = parent_obj.BIMObjectProperties.collection
|
||||||
for child in obj.users_collection[0].children:
|
for child in collection.children:
|
||||||
parent_collection.children.link(child)
|
parent_collection.children.link(child)
|
||||||
bpy.data.collections.remove(obj.users_collection[0])
|
bpy.data.collections.remove(collection)
|
||||||
if getattr(element, "FillsVoids", None):
|
if getattr(element, "FillsVoids", None):
|
||||||
bpy.ops.bim.remove_filling(filling=element.id())
|
bpy.ops.bim.remove_filling(filling=element.id())
|
||||||
|
|
||||||
|
|||||||
@@ -161,17 +161,4 @@ class Root(blenderbim.core.tool.Root):
|
|||||||
if "/" in name and name.split("/")[0][0:3] == "Ifc":
|
if "/" in name and name.split("/")[0][0:3] == "Ifc":
|
||||||
name = "/".join(name.split("/")[1:])
|
name = "/".join(name.split("/")[1:])
|
||||||
name = "{}/{}".format(element.is_a(), name)
|
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
|
obj.name = name
|
||||||
|
|
||||||
if existing_obj:
|
|
||||||
if existing_collection:
|
|
||||||
existing_collection.name = existing_obj.name
|
|
||||||
|
|||||||
Reference in New Issue
Block a user