mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Activating a drawing now automatically switches to the preferred target view representation of all elements
This commit is contained in:
@@ -1351,18 +1351,46 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
bpy.data.collections.get(camera.users_collection[0].name).hide_render = False
|
bpy.data.collections.get(camera.users_collection[0].name).hide_render = False
|
||||||
tool.Spatial.set_active_object(camera)
|
tool.Spatial.set_active_object(camera)
|
||||||
|
|
||||||
# sync viewport objects visibility with selectors from EPset_Drawing/Include and /Exclude
|
# Sync viewport objects visibility with selectors from EPset_Drawing/Include and /Exclude
|
||||||
ifc_file = tool.Ifc.get()
|
|
||||||
drawing = tool.Ifc.get_entity(camera)
|
drawing = tool.Ifc.get_entity(camera)
|
||||||
all_drawing_elements = set(ifc_file.by_type("IfcElement"))
|
all_elements = set(tool.Ifc.get().by_type("IfcElement")) - set(tool.Ifc.get().by_type("IfcOpeningElement"))
|
||||||
annotations = tool.Drawing.get_group_elements(tool.Drawing.get_drawing_group(drawing))
|
filtered_elements = cls.get_drawing_elements(drawing)
|
||||||
all_drawing_elements.update(annotations)
|
hidden_elements = list(all_elements - filtered_elements)
|
||||||
filtered_drawing_elements = cls.get_drawing_elements(drawing)
|
hidden_objs = [tool.Ifc.get_object(e) for e in hidden_elements]
|
||||||
|
|
||||||
for element in all_drawing_elements:
|
# Running operators is much more efficient in this scenario than looping through each element
|
||||||
if element.is_a() in ("IfcOpeningElement",):
|
bpy.ops.object.hide_view_clear()
|
||||||
continue
|
|
||||||
|
|
||||||
|
for hidden_obj in hidden_objs:
|
||||||
|
hidden_obj.hide_set(True)
|
||||||
|
hidden_obj.hide_render = True
|
||||||
|
|
||||||
|
subcontexts = []
|
||||||
|
target_view = cls.get_drawing_target_view(drawing)
|
||||||
|
context_filters = [("Model", "Body", target_view), ("Model", "Body", "MODEL_VIEW")]
|
||||||
|
if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW"):
|
||||||
|
plan_contexts = [("Plan", "Body", target_view), ("Plan", "Body", "MODEL_VIEW")]
|
||||||
|
plan_contexts.extend(context_filters)
|
||||||
|
context_filters = plan_contexts
|
||||||
|
for context_filter in context_filters:
|
||||||
|
subcontext = ifcopenshell.util.representation.get_context(tool.Ifc.get(), *context_filter)
|
||||||
|
if subcontext:
|
||||||
|
subcontexts.append(context_filter)
|
||||||
|
|
||||||
|
for element in filtered_elements:
|
||||||
obj = tool.Ifc.get_object(element)
|
obj = tool.Ifc.get_object(element)
|
||||||
obj.hide_set(element not in filtered_drawing_elements)
|
for subcontext in subcontexts:
|
||||||
obj.hide_render = element not in filtered_drawing_elements
|
priority_representation = ifcopenshell.util.representation.get_representation(element, *subcontext)
|
||||||
|
if priority_representation:
|
||||||
|
current_representation = tool.Geometry.get_active_representation(obj)
|
||||||
|
if current_representation != priority_representation:
|
||||||
|
blenderbim.core.geometry.switch_representation(
|
||||||
|
tool.Ifc,
|
||||||
|
tool.Geometry,
|
||||||
|
obj=obj,
|
||||||
|
representation=priority_representation,
|
||||||
|
should_reload=False,
|
||||||
|
is_global=True,
|
||||||
|
should_sync_changes_first=True,
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user