From 9d8aeccfe3757dbb910f61cec7ec29446d880ad9 Mon Sep 17 00:00:00 2001 From: Alan Odom Date: Sun, 16 Feb 2020 19:53:00 +0000 Subject: PDT: Add Local View Options (enhancement) Add local view orientation options to Delta & Direction options for all functions. --- precision_drawing_tools/pdt_command.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'precision_drawing_tools') diff --git a/precision_drawing_tools/pdt_command.py b/precision_drawing_tools/pdt_command.py index dc30d2ff..5b4b30c1 100644 --- a/precision_drawing_tools/pdt_command.py +++ b/precision_drawing_tools/pdt_command.py @@ -32,6 +32,8 @@ from .pdt_functions import ( obj_check, oops, update_sel, + view_coords, + view_dir, ) from .pdt_command_functions import ( vector_build, @@ -535,6 +537,10 @@ def move_cursor_pivot(context, pg, operation, mode, obj, verts, values): elif operation == "P": pg.pivot_loc = vector_delta elif mode in {"d", "i"}: + if pg.plane == "LO" and mode == "d": + vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z) + elif pg.plane == "LO" and mode == "i": + vector_delta = view_dir(pg.distance, pg.angle) if mode_sel == "REL": if operation == "C": scene.cursor.location = scene.cursor.location + vector_delta @@ -613,6 +619,12 @@ def move_entities(context, pg, operation, mode, obj, bm, verts, values): vector_delta = vector_build(context, pg, obj, operation, values, 2) except: raise PDT_InvalidVector + + if pg.plane == "LO" and mode == "d": + vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z) + elif pg.plane == "LO" and mode == "i": + vector_delta = view_dir(pg.distance, pg.angle) + if obj.mode == "EDIT": bmesh.ops.translate( bm, verts=[v for v in bm.verts if v.select], vec=vector_delta @@ -670,6 +682,8 @@ def add_new_vertex(context, pg, operation, mode, obj, bm, verts, values): vector_delta = vector_build(context, pg, obj, operation, values, 3) except: raise PDT_InvalidVector + if pg.plane == "LO": + vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z) new_vertex = bm.verts.new(verts[-1].co + vector_delta) # Direction/Polar Coordinates elif mode == "i": @@ -677,6 +691,8 @@ def add_new_vertex(context, pg, operation, mode, obj, bm, verts, values): vector_delta = vector_build(context, pg, obj, operation, values, 2) except: raise PDT_InvalidVector + if pg.plane == "LO": + vector_delta = view_dir(pg.distance, pg.angle) new_vertex = bm.verts.new(verts[-1].co + vector_delta) # Percent Options Only Other Choice else: @@ -840,6 +856,8 @@ def extrude_vertices(context, pg, operation, mode, obj, obj_loc, bm, verts, valu vector_delta = vector_build(context, pg, obj, operation, values, 3) except: raise PDT_InvalidVector + if pg.plane == "LO": + vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z) for v in verts: new_vertex = bm.verts.new(v.co) new_vertex.co = new_vertex.co + vector_delta @@ -852,6 +870,8 @@ def extrude_vertices(context, pg, operation, mode, obj, obj_loc, bm, verts, valu vector_delta = vector_build(context, pg, obj, operation, values, 2) except: raise PDT_InvalidVector + if pg.plane == "LO": + vector_delta = view_dir(pg.distance, pg.angle) for v in verts: new_vertex = bm.verts.new(v.co) new_vertex.co = new_vertex.co + vector_delta @@ -925,6 +945,12 @@ def extrude_geometry(context, pg, operation, mode, obj, bm, values): edges_extr = [e for e in geom_extr if isinstance(e, bmesh.types.BMEdge)] faces_extr = [f for f in geom_extr if isinstance(f, bmesh.types.BMFace)] del ret + + if pg.plane == "LO" and mode == "d": + vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z) + elif pg.plane == "LO" and mode == "i": + vector_delta = view_dir(pg.distance, pg.angle) + bmesh.ops.translate(bm, verts=verts_extr, vec=vector_delta) update_sel(bm, verts_extr, edges_extr, faces_extr) bmesh.update_edit_mesh(obj.data) @@ -978,6 +1004,12 @@ def duplicate_geometry(context, pg, operation, mode, obj, bm, values): edges_dupe = [e for e in geom_dupe if isinstance(e, bmesh.types.BMEdge)] faces_dupe = [f for f in geom_dupe if isinstance(f, bmesh.types.BMFace)] del ret + + if pg.plane == "LO" and mode == "d": + vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z) + elif pg.plane == "LO" and mode == "i": + vector_delta = view_dir(pg.distance, pg.angle) + bmesh.ops.translate(bm, verts=verts_dupe, vec=vector_delta) update_sel(bm, verts_dupe, edges_dupe, faces_dupe) bmesh.update_edit_mesh(obj.data) -- cgit v1.2.3