From 60e4de5ffa4b32c4134691631dbea84fea9a86d4 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 29 Sep 2022 22:33:26 +1000 Subject: [PATCH] You can now align the view to the edited profile, for angled profiles --- .../blenderbim/bim/module/cad/__init__.py | 1 + .../blenderbim/bim/module/cad/operator.py | 30 +++++++++++++++++++ .../blenderbim/bim/module/cad/workspace.py | 1 + 3 files changed, 32 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/cad/__init__.py b/src/blenderbim/blenderbim/bim/module/cad/__init__.py index 8285a64ebc..9cd2103ca9 100644 --- a/src/blenderbim/blenderbim/bim/module/cad/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/cad/__init__.py @@ -20,6 +20,7 @@ import bpy from . import operator, prop, workspace classes = ( + operator.AlignViewToProfile, operator.AddIfcArcIndexFillet, operator.AddIfcCircle, operator.CadArcFrom2Points, diff --git a/src/blenderbim/blenderbim/bim/module/cad/operator.py b/src/blenderbim/blenderbim/bim/module/cad/operator.py index b1cd820911..0e4e83bd77 100644 --- a/src/blenderbim/blenderbim/bim/module/cad/operator.py +++ b/src/blenderbim/blenderbim/bim/module/cad/operator.py @@ -751,3 +751,33 @@ class AddIfcArcIndexFillet(bpy.types.Operator): bm.verts.index_update() bm.edges.index_update() bmesh.update_edit_mesh(obj.data) + + +class AlignViewToProfile(bpy.types.Operator): + bl_idname = "bim.align_view_to_profile" + bl_label = "Align View To Profile" + # __ ___ + # .'. -- . '. + # /U) __ (O| + # /.' ()() '.\._ + # .',/;,_.--._.;;) . '--..__ + # / ,///|.__.|.\\\ \ '. '.''---..___ + # /'._ '' || || '' _'\ : \ ' . '. + # / || || '., ) ) : \ + # :'-.__ _ || || _ __.' _\_ .' ' ' ,) + # ( ' |' ( __= ___..-._ ( (.\\ + # ('\ .___ ___. /'.___= \.\.\ + # \\\-..____________..-'/// + + @classmethod + def poll(cls, context): + obj = context.active_object + return bool(obj) and obj.type == "MESH" + + def execute(self, context): + bpy.ops.object.mode_set(mode="OBJECT") + bpy.ops.view3d.view_axis(type="TOP", align_active=True) + region_3d = bpy.context.area.spaces.active.region_3d + region_3d.view_perspective = "ORTHO" + bpy.ops.object.mode_set(mode="EDIT") + return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/cad/workspace.py b/src/blenderbim/blenderbim/bim/module/cad/workspace.py index 61d8cc06e6..91356412fa 100644 --- a/src/blenderbim/blenderbim/bim/module/cad/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/cad/workspace.py @@ -51,6 +51,7 @@ class CadTool(WorkSpaceTool): row.label(text="", icon="EVENT_SHIFT") row.label(text="", icon="EVENT_Q") row.operator("bim.edit_extrusion_profile", text="Save Profile") + row.operator("bim.align_view_to_profile", text="", icon="AXIS_FRONT") row.operator("bim.disable_editing_extrusion_profile", text="", icon="CANCEL") row = layout.row(align=True)