mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 11:18:18 +00:00
Collector now unassigns from old ifc collections
This commit is contained in:
@@ -1261,7 +1261,7 @@ class IfcImporter:
|
|||||||
def place_objects_in_collections(self) -> None:
|
def place_objects_in_collections(self) -> None:
|
||||||
for ifc_definition_id, obj in self.added_data.items():
|
for ifc_definition_id, obj in self.added_data.items():
|
||||||
if isinstance(obj, bpy.types.Object):
|
if isinstance(obj, bpy.types.Object):
|
||||||
tool.Collector.assign(obj)
|
tool.Collector.assign(obj, should_clean_users_collection=False)
|
||||||
|
|
||||||
def is_curve_annotation(self, element: ifcopenshell.entity_instance) -> bool:
|
def is_curve_annotation(self, element: ifcopenshell.entity_instance) -> bool:
|
||||||
object_type = element.ObjectType
|
object_type = element.ObjectType
|
||||||
|
|||||||
@@ -25,8 +25,20 @@ from typing import Union
|
|||||||
|
|
||||||
class Collector(blenderbim.core.tool.Collector):
|
class Collector(blenderbim.core.tool.Collector):
|
||||||
@classmethod
|
@classmethod
|
||||||
def assign(cls, obj: bpy.types.Object) -> None:
|
def assign(cls, obj: bpy.types.Object, should_clean_users_collection=True) -> None:
|
||||||
"""Links an object to an appropriate Blender collection."""
|
"""Links an object to an appropriate Blender collection."""
|
||||||
|
if should_clean_users_collection:
|
||||||
|
for users_collection in obj.users_collection:
|
||||||
|
if obj.BIMObjectProperties.collection == users_collection:
|
||||||
|
continue
|
||||||
|
# Users are free to user extra collections for their own
|
||||||
|
# purposes except for the reserved keyword "Ifc" and
|
||||||
|
# "Collection" (which is the default collection that comes with
|
||||||
|
# a Blender session)
|
||||||
|
if "Ifc" in users_collection.name or users_collection.name == "Collection":
|
||||||
|
print('removing', users_collection, 'from', obj)
|
||||||
|
users_collection.objects.unlink(obj)
|
||||||
|
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
|
||||||
if element.is_a("IfcGridAxis"):
|
if element.is_a("IfcGridAxis"):
|
||||||
|
|||||||
Reference in New Issue
Block a user