mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
shift+click, to quickly switch the drawing view without turning anything on or off in the scene. as discussed: https://community.osarch.org/discussion/2196/quick-way-to-switch-between-drawing-views#latest
shift+click, to quickly switch the drawing view without turning anything on or off in the scene. as discussed: https://community.osarch.org/discussion/2196/quick-way-to-switch-between-drawing-views#latest
This commit is contained in:
@@ -1513,16 +1513,20 @@ class ActivateDrawing(bpy.types.Operator):
|
|||||||
bl_idname = "bim.activate_drawing"
|
bl_idname = "bim.activate_drawing"
|
||||||
bl_label = "Activate Drawing"
|
bl_label = "Activate Drawing"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
bl_description = "Activates the selected drawing view.\n\n" + "ALT+CLICK to keep the viewport position"
|
bl_description = "Activates the selected drawing view.\n\n" + "ALT+CLICK to keep the viewport position.\n\n" + "SHIFT+CLICK activiate drawing without turning objects on/off."
|
||||||
|
|
||||||
drawing: bpy.props.IntProperty()
|
drawing: bpy.props.IntProperty()
|
||||||
camera_view_point: bpy.props.BoolProperty(name="Camera View Point", default=True, options={"SKIP_SAVE"})
|
camera_view_point: bpy.props.BoolProperty(name="Camera View Point", default=True, options={"SKIP_SAVE"})
|
||||||
|
switch_camera_only: bpy.props.BoolProperty(name="Only Changes Camera View", default=False, options={"SKIP_SAVE"})
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
# keep the viewport position on alt+click
|
# keep the viewport position on alt+click
|
||||||
# make sure to use SKIP_SAVE on property, otherwise it might get stuck
|
# make sure to use SKIP_SAVE on property, otherwise it might get stuck
|
||||||
if event.type == "LEFTMOUSE" and event.alt:
|
if event.type == "LEFTMOUSE" and event.alt:
|
||||||
self.camera_view_point = False
|
self.camera_view_point = False
|
||||||
|
# Only activates the camera view on shift+click. Does not turn on/off objects in scene
|
||||||
|
if event.type == "LEFTMOUSE" and event.shift:
|
||||||
|
self.switch_camera_only = True
|
||||||
return self.execute(context)
|
return self.execute(context)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
@@ -1531,30 +1535,34 @@ class ActivateDrawing(bpy.types.Operator):
|
|||||||
drawing = tool.Ifc.get().by_id(self.drawing)
|
drawing = tool.Ifc.get().by_id(self.drawing)
|
||||||
dprops = bpy.context.scene.DocProperties
|
dprops = bpy.context.scene.DocProperties
|
||||||
|
|
||||||
if not self.camera_view_point:
|
if self.switch_camera_only:
|
||||||
viewport_position = tool.Blender.get_viewport_position()
|
camera = tool.Drawing.import_drawing(drawing)
|
||||||
|
tool.Blender.activate_camera(camera)
|
||||||
|
else:
|
||||||
|
if not self.camera_view_point:
|
||||||
|
viewport_position = tool.Blender.get_viewport_position()
|
||||||
|
|
||||||
core.activate_drawing_view(tool.Ifc, tool.Blender, tool.Drawing, drawing=drawing)
|
core.activate_drawing_view(tool.Ifc, tool.Blender, tool.Drawing, drawing=drawing)
|
||||||
|
|
||||||
if not self.camera_view_point:
|
if not self.camera_view_point:
|
||||||
tool.Blender.set_viewport_position(viewport_position)
|
tool.Blender.set_viewport_position(viewport_position)
|
||||||
|
|
||||||
dprops.active_drawing_id = self.drawing
|
dprops.active_drawing_id = self.drawing
|
||||||
# reset DrawingsData to reload_drawing_styles work correctly
|
# reset DrawingsData to reload_drawing_styles work correctly
|
||||||
DrawingsData.is_loaded = False
|
DrawingsData.is_loaded = False
|
||||||
dprops.drawing_styles.clear()
|
dprops.drawing_styles.clear()
|
||||||
if ifcopenshell.util.element.get_pset(drawing, "EPset_Drawing", "HasUnderlay"):
|
if ifcopenshell.util.element.get_pset(drawing, "EPset_Drawing", "HasUnderlay"):
|
||||||
bpy.ops.bim.reload_drawing_styles()
|
bpy.ops.bim.reload_drawing_styles()
|
||||||
bpy.ops.bim.activate_drawing_style()
|
bpy.ops.bim.activate_drawing_style()
|
||||||
core.sync_references(tool.Ifc, tool.Collector, tool.Drawing, drawing=tool.Ifc.get().by_id(self.drawing))
|
core.sync_references(tool.Ifc, tool.Collector, tool.Drawing, drawing=tool.Ifc.get().by_id(self.drawing))
|
||||||
CutDecorator.install(context)
|
CutDecorator.install(context)
|
||||||
tool.Drawing.show_decorations()
|
tool.Drawing.show_decorations()
|
||||||
|
|
||||||
# Save drawing bounds to the .ifc file
|
# Save drawing bounds to the .ifc file
|
||||||
camera = context.scene.camera
|
camera = context.scene.camera
|
||||||
camera_props = camera.data.BIMCameraProperties
|
camera_props = camera.data.BIMCameraProperties
|
||||||
if camera_props.update_representation(camera):
|
if camera_props.update_representation(camera):
|
||||||
bpy.ops.bim.update_representation(obj=camera.name, ifc_representation_class="")
|
bpy.ops.bim.update_representation(obj=camera.name, ifc_representation_class="")
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user