diff --git a/src/blenderbim/blenderbim/tool/root.py b/src/blenderbim/blenderbim/tool/root.py index 42a39f8881..3bb9b4f42d 100644 --- a/src/blenderbim/blenderbim/tool/root.py +++ b/src/blenderbim/blenderbim/tool/root.py @@ -155,14 +155,23 @@ class Root(blenderbim.core.tool.Root): profile_set_usage=profile_set_usage, ) - @classmethod - def set_element_specific_display_settings(cls, obj, element): - if element.is_a("IfcOpeningElement"): - obj.display_type = "WIRE" - @classmethod def set_object_name(cls, obj, element): name = obj.name if "/" in name and name.split("/")[0][0:3] == "Ifc": name = "/".join(name.split("/")[1:]) - obj.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 + + if existing_obj: + if existing_collection: + existing_collection.name = existing_obj.name