mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Fix #5244. Prioritise collection of drawing groups over containment groups
This commit is contained in:
@@ -1770,7 +1770,10 @@ class ReloadDrawingStyles(bpy.types.Operator):
|
|||||||
drawing_style.raster_style = json.dumps(style_data["raster_style"])
|
drawing_style.raster_style = json.dumps(style_data["raster_style"])
|
||||||
|
|
||||||
if current_style is not None:
|
if current_style is not None:
|
||||||
camera_props.active_drawing_style_index = styles.index(current_style)
|
try:
|
||||||
|
camera_props.active_drawing_style_index = styles.index(current_style)
|
||||||
|
except ValueError:
|
||||||
|
self.report({"INFO"}, f"Could not find style {current_style} in EPset_Drawing.ShadingStyles.")
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|||||||
@@ -79,26 +79,19 @@ class Collector(bonsai.core.tool.Collector):
|
|||||||
cls.link_to_collection_safe(obj, collection)
|
cls.link_to_collection_safe(obj, collection)
|
||||||
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
||||||
cls.link_to_collection_safe(collection, project_obj.BIMObjectProperties.collection)
|
cls.link_to_collection_safe(collection, project_obj.BIMObjectProperties.collection)
|
||||||
|
elif element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING":
|
||||||
|
if collection := cls._create_own_collection(obj):
|
||||||
|
cls.link_to_collection_safe(obj, collection)
|
||||||
|
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
||||||
|
cls.link_to_collection_safe(collection, project_obj.BIMObjectProperties.collection)
|
||||||
|
elif element.is_a("IfcAnnotation") and (drawing_obj := cls.get_annotation_drawing_obj(element)):
|
||||||
|
cls.link_to_collection_safe(obj, drawing_obj.BIMObjectProperties.collection)
|
||||||
elif container := ifcopenshell.util.element.get_container(element):
|
elif container := ifcopenshell.util.element.get_container(element):
|
||||||
container_obj = tool.Ifc.get_object(container)
|
container_obj = tool.Ifc.get_object(container)
|
||||||
if not (collection := container_obj.BIMObjectProperties.collection):
|
if not (collection := container_obj.BIMObjectProperties.collection):
|
||||||
cls.assign(container_obj)
|
cls.assign(container_obj)
|
||||||
collection = container_obj.BIMObjectProperties.collection
|
collection = container_obj.BIMObjectProperties.collection
|
||||||
cls.link_to_collection_safe(obj, collection)
|
cls.link_to_collection_safe(obj, collection)
|
||||||
elif element.is_a("IfcAnnotation"):
|
|
||||||
if element.ObjectType == "DRAWING":
|
|
||||||
if collection := cls._create_own_collection(obj):
|
|
||||||
cls.link_to_collection_safe(obj, collection)
|
|
||||||
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
|
||||||
cls.link_to_collection_safe(collection, project_obj.BIMObjectProperties.collection)
|
|
||||||
else:
|
|
||||||
for rel in element.HasAssignments or []:
|
|
||||||
if rel.is_a("IfcRelAssignsToGroup") and rel.RelatingGroup.ObjectType == "DRAWING":
|
|
||||||
for related_object in rel.RelatedObjects:
|
|
||||||
if related_object.is_a("IfcAnnotation") and related_object.ObjectType == "DRAWING":
|
|
||||||
drawing_obj = tool.Ifc.get_object(related_object)
|
|
||||||
if drawing_obj:
|
|
||||||
cls.link_to_collection_safe(obj, drawing_obj.BIMObjectProperties.collection)
|
|
||||||
else:
|
else:
|
||||||
collection = cls._create_project_child_collection("Unsorted")
|
collection = cls._create_project_child_collection("Unsorted")
|
||||||
collection.hide_viewport = False
|
collection.hide_viewport = False
|
||||||
@@ -126,6 +119,14 @@ class Collector(bonsai.core.tool.Collector):
|
|||||||
collection.BIMCollectionProperties.obj = obj
|
collection.BIMCollectionProperties.obj = obj
|
||||||
return collection
|
return collection
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_annotation_drawing_obj(cls, element: ifcopenshell.entity_instance) -> bpy.types.Object | None:
|
||||||
|
for rel in element.HasAssignments or []:
|
||||||
|
if rel.is_a("IfcRelAssignsToGroup") and rel.RelatingGroup.ObjectType == "DRAWING":
|
||||||
|
for related_object in rel.RelatedObjects:
|
||||||
|
if related_object.is_a("IfcAnnotation") and related_object.ObjectType == "DRAWING":
|
||||||
|
return tool.Ifc.get_object(related_object)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def link_to_collection_safe(
|
def link_to_collection_safe(
|
||||||
cls, obj_or_col: Union[bpy.types.Object, bpy.types.Collection], collection: bpy.types.Collection
|
cls, obj_or_col: Union[bpy.types.Object, bpy.types.Collection], collection: bpy.types.Collection
|
||||||
|
|||||||
Reference in New Issue
Block a user