mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
New activate model operator to switch back to a MODEL_VIEW target view subcontext
This commit is contained in:
@@ -20,8 +20,9 @@ import bpy
|
||||
from . import ui, prop, operator, handler, gizmos
|
||||
|
||||
classes = (
|
||||
operator.ActivateDrawing,
|
||||
operator.ActivateDrawingStyle,
|
||||
operator.ActivateView,
|
||||
operator.ActivateModel,
|
||||
operator.AddAnnotation,
|
||||
operator.AddDrawing,
|
||||
operator.AddDrawingStyle,
|
||||
|
||||
@@ -176,7 +176,7 @@ class CreateDrawing(bpy.types.Operator):
|
||||
|
||||
for drawing_id in drawings_to_print:
|
||||
if self.print_all:
|
||||
bpy.ops.bim.activate_view(drawing=drawing_id)
|
||||
bpy.ops.bim.activate_drawing(drawing=drawing_id)
|
||||
|
||||
self.camera = context.scene.camera
|
||||
self.camera_element = tool.Ifc.get_entity(self.camera)
|
||||
@@ -218,7 +218,7 @@ class CreateDrawing(bpy.types.Operator):
|
||||
open_with_user_command(context.preferences.addons["blenderbim"].preferences.svg_command, svg_path)
|
||||
|
||||
if self.print_all:
|
||||
bpy.ops.bim.activate_view(drawing=original_drawing_id)
|
||||
bpy.ops.bim.activate_drawing(drawing=original_drawing_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
def get_camera_dimensions(self):
|
||||
@@ -978,13 +978,47 @@ class OpenDrawing(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ActivateView(bpy.types.Operator):
|
||||
class ActivateModel(bpy.types.Operator):
|
||||
bl_idname = "bim.activate_model"
|
||||
bl_label = "Activate Model"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = "Activates the model view"
|
||||
|
||||
def execute(self, context):
|
||||
CutDecorator.uninstall()
|
||||
|
||||
bpy.ops.object.hide_view_clear()
|
||||
|
||||
subcontext = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW")
|
||||
|
||||
for obj in context.visible_objects:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if not element:
|
||||
continue
|
||||
model = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||
if model:
|
||||
current_representation = tool.Geometry.get_active_representation(obj)
|
||||
if current_representation != model:
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=model,
|
||||
should_reload=False,
|
||||
is_global=True,
|
||||
should_sync_changes_first=True,
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
class ActivateDrawing(bpy.types.Operator):
|
||||
"""
|
||||
Activates the selected drawing view
|
||||
"""
|
||||
|
||||
bl_idname = "bim.activate_view"
|
||||
bl_label = "Activate View"
|
||||
bl_idname = "bim.activate_drawing"
|
||||
bl_label = "Activate Drawing"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = "Activates the selected drawing view"
|
||||
drawing: bpy.props.IntProperty()
|
||||
|
||||
@@ -196,7 +196,8 @@ class BIM_PT_drawings(Panel):
|
||||
op = row.operator("bim.select_all_drawings", icon="SELECT_SUBTRACT", text="")
|
||||
op = row.operator("bim.open_drawing", icon="URL", text="")
|
||||
op.view = active_drawing.name
|
||||
op = row.operator("bim.activate_view", icon="OUTLINER_OB_CAMERA", text="")
|
||||
row.operator("bim.activate_model", icon="VIEW3D", text="")
|
||||
op = row.operator("bim.activate_drawing", icon="OUTLINER_OB_CAMERA", text="")
|
||||
op.drawing = active_drawing.ifc_definition_id
|
||||
row.operator("bim.create_drawing", text="", icon="OUTPUT")
|
||||
self.layout.template_list(
|
||||
|
||||
@@ -386,4 +386,4 @@ def activate_drawing_view(ifc, drawing_tool, drawing):
|
||||
if not camera:
|
||||
camera = drawing_tool.import_drawing(drawing)
|
||||
drawing_tool.import_annotations_in_group(drawing_tool.get_drawing_group(drawing))
|
||||
drawing_tool.activate_view(camera)
|
||||
drawing_tool.activate_drawing(camera)
|
||||
|
||||
@@ -225,7 +225,7 @@ class Document:
|
||||
|
||||
@interface
|
||||
class Drawing:
|
||||
def activate_view(cls, camera): pass
|
||||
def activate_drawing(cls, camera): pass
|
||||
def add_literal_to_annotation(cls, obj, Literal='Literal', Path='RIGHT', BoxAlignment='bottom-left'): pass
|
||||
def copy_representation(cls, source, dest): pass
|
||||
def create_annotation_object(cls, drawing, object_type): pass
|
||||
|
||||
@@ -1324,7 +1324,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
return True if (camera and camera.data.type == "ORTHO") else False
|
||||
|
||||
@classmethod
|
||||
def activate_view(cls, camera):
|
||||
def activate_drawing(cls, camera):
|
||||
area = next(area for area in bpy.context.screen.areas if area.type == "VIEW_3D")
|
||||
is_local_view = area.spaces[0].local_view is not None
|
||||
if is_local_view:
|
||||
|
||||
Reference in New Issue
Block a user