Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRune Morling <ermo.blender.org@spammesenseless.net>2021-05-17 20:30:35 +0300
committerRune Morling <ermo.blender.org@spammesenseless.net>2021-05-17 20:43:36 +0300
commite2516bfae6d05f060017a9940614ad83dc533f29 (patch)
treea4cfc608102816bb5b3fcbc06e43d0245a446d3b
parent26d3cfb04ec0a7f14d2a6ff607cbec574e8dcef7 (diff)
PDT: Add "View Normal" Operation enhancement
This enhancement enables the user to work always Normal to the View as defined by "Working Plane" in PDT Design Functions Section. For example: If the working plane is set to Front and the Operation is "Extrude Geometry" the system will extrude along the Y axis by the amount specified in the "Distance" Entry Box. Specifying Working Plane as "View" cause the system to work always Normal to the current view orientation, i.e. into, or out of your screen. This enhancement is only available for Blender 2.9x builds.
-rw-r--r--precision_drawing_tools/__init__.py3
-rw-r--r--precision_drawing_tools/pdt_command.py57
-rw-r--r--precision_drawing_tools/pdt_design.py82
-rw-r--r--precision_drawing_tools/pdt_menus.py5
-rw-r--r--precision_drawing_tools/pdt_msg_strings.py1
5 files changed, 125 insertions, 23 deletions
diff --git a/precision_drawing_tools/__init__.py b/precision_drawing_tools/__init__.py
index 42c41f79..9a688e30 100644
--- a/precision_drawing_tools/__init__.py
+++ b/precision_drawing_tools/__init__.py
@@ -29,7 +29,7 @@
bl_info = {
"name": "Precision Drawing Tools (PDT)",
"author": "Alan Odom (Clockmender), Rune Morling (ermo)",
- "version": (1, 4, 2),
+ "version": (1, 4, 3),
"blender": (2, 90, 0),
"location": "View3D > UI > PDT",
"description": "Precision Drawing Tools for Acccurate Modelling",
@@ -520,6 +520,7 @@ classes = (
pdt_design.PDT_OT_PlacementAbs,
pdt_design.PDT_OT_PlacementDelta,
pdt_design.PDT_OT_PlacementDis,
+ pdt_design.PDT_OT_PlacementView,
pdt_design.PDT_OT_PlacementCen,
pdt_design.PDT_OT_PlacementPer,
pdt_design.PDT_OT_PlacementNormal,
diff --git a/precision_drawing_tools/pdt_command.py b/precision_drawing_tools/pdt_command.py
index 384e857d..57415b7b 100644
--- a/precision_drawing_tools/pdt_command.py
+++ b/precision_drawing_tools/pdt_command.py
@@ -220,9 +220,9 @@ def command_run(self, context):
mode = command[1].lower()
if (
(operation == "F" and mode not in {"v", "e", "i"})
- or (operation in {"D", "E"} and mode not in {"d", "i"})
+ or (operation in {"D", "E"} and mode not in {"d", "i", "v"}) #new
or (operation == "M" and mode not in {"a", "d", "i", "p", "o", "x", "y", "z"})
- or (operation not in {"D", "E", "F", "M"} and mode not in {"a", "d", "i", "p"})
+ or (operation not in {"D", "E", "F", "M"} and mode not in {"a", "d", "i", "p", "v"}) #new
):
pg.error = f"'{mode}' {PDT_ERR_NON_VALID} '{operation}'"
context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
@@ -322,15 +322,15 @@ def pdt_help(self, context):
label = self.layout.label
label(text="Primary Letters (Available Secondary Letters):")
label(text="")
- label(text="C: Cursor (a, d, i, p)")
- label(text="D: Duplicate Geometry (d, i)")
- label(text="E: Extrude Geometry (d, i)")
+ label(text="C: Cursor (a, d, i, p, v)")
+ label(text="D: Duplicate Geometry (d, i, v)")
+ label(text="E: Extrude Geometry (d, i, v)")
label(text="F: Fillet (v, e, i)")
- label(text="G: Grab (Move) (a, d, i, p)")
- label(text="N: New Vertex (a, d, i, p)")
+ label(text="G: Grab (Move) (a, d, i, p, v)")
+ label(text="N: New Vertex (a, d, i, p, v)")
label(text="M: Maths Functions (a, d, p, o, x, y, z)")
- label(text="P: Pivot Point (a, d, i, p)")
- label(text="V: Extrude Vertice Only (a, d, i, p)")
+ label(text="P: Pivot Point (a, d, i, p, v)")
+ label(text="V: Extrude Vertice Only (a, d, i, p, v)")
label(text="S: Split Edges (a, d, i, p)")
label(text="?: Quick Help")
label(text="")
@@ -341,6 +341,8 @@ def pdt_help(self, context):
label(text="d: Delta (Relative) Coordinates, e.g. 0.5,0,1.2")
label(text="i: Directional (Polar) Coordinates e.g. 2.6,45")
label(text="p: Percent e.g. 67.5")
+ label(text="v: Work in View Normal Axis")
+ label(text="")
label(text="- Fillet Options:")
label(text="v: Fillet Vertices")
label(text="e: Fillet Edges")
@@ -438,6 +440,19 @@ def command_parse(context):
except ValueError:
values[ind] = "0.0"
ind = ind + 1
+ if mode == "v":
+ # View relative mode
+ if pg.plane == "XZ":
+ values = [0.0, values[0], 0.0]
+ elif pg.plane == "YZ":
+ values = [values[0], 0.0, 0.0]
+ elif pg.plane == "XY":
+ values = [0.0, 0.0, values[0]]
+ else:
+ if "-" in values[0]:
+ values = [0.0, 0.0, values[0][1:]]
+ else:
+ values = [0.0, 0.0, f"-{values[0]}"]
# Apply System Rounding
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
values_out = [str(round(float(v), decimal_places)) for v in values]
@@ -507,7 +522,7 @@ def move_cursor_pivot(context, pg, operation, mode, obj, verts, values):
"""
# Absolute/Global Coordinates, or Delta/Relative Coordinates
- if mode in {"a", "d"}:
+ if mode in {"a", "d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@@ -537,8 +552,8 @@ def move_cursor_pivot(context, pg, operation, mode, obj, verts, values):
scene.cursor.location = vector_delta
elif operation == "P":
pg.pivot_loc = vector_delta
- elif mode in {"d", "i"}:
- if pg.plane == "LO" and mode == "d":
+ elif mode in {"d", "i", "v"}:
+ if pg.plane == "LO" and mode in {"d", "v"}:
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)
@@ -607,8 +622,8 @@ def move_entities(context, pg, operation, mode, obj, bm, verts, values):
for ob in context.view_layer.objects.selected:
ob.location = vector_delta
- elif mode in {"d", "i"}:
- if mode == "d":
+ elif mode in {"d", "i", "v"}:
+ if mode in {"d", "v"}:
# Delta/Relative Coordinates
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
@@ -621,7 +636,7 @@ def move_entities(context, pg, operation, mode, obj, bm, verts, values):
except:
raise PDT_InvalidVector
- if pg.plane == "LO" and mode == "d":
+ if pg.plane == "LO" and mode in {"d", "v"}:
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)
@@ -678,7 +693,7 @@ def add_new_vertex(context, pg, operation, mode, obj, bm, verts, values):
raise PDT_InvalidVector
new_vertex = bm.verts.new(vector_delta - obj_loc)
# Delta/Relative Coordinates
- elif mode == "d":
+ elif mode in {"d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@@ -852,7 +867,7 @@ def extrude_vertices(context, pg, operation, mode, obj, obj_loc, bm, verts, valu
bm, verts=[v for v in bm.verts if v.select], dist=0.0001
)
# Delta/Relative Coordinates
- elif mode == "d":
+ elif mode in {"d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@@ -920,7 +935,7 @@ def extrude_geometry(context, pg, operation, mode, obj, bm, values):
context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
return
# Delta/Relative Coordinates
- if mode == "d":
+ if mode in {"d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@@ -947,7 +962,7 @@ def extrude_geometry(context, pg, operation, mode, obj, bm, values):
faces_extr = [f for f in geom_extr if isinstance(f, bmesh.types.BMFace)]
del ret
- if pg.plane == "LO" and mode == "d":
+ if pg.plane == "LO" and mode in {"d", "v"}:
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)
@@ -979,7 +994,7 @@ def duplicate_geometry(context, pg, operation, mode, obj, bm, values):
context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
return
# Delta/Relative Coordinates
- if mode == "d":
+ if mode in {"d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@@ -1006,7 +1021,7 @@ def duplicate_geometry(context, pg, operation, mode, obj, bm, values):
faces_dupe = [f for f in geom_dupe if isinstance(f, bmesh.types.BMFace)]
del ret
- if pg.plane == "LO" and mode == "d":
+ if pg.plane == "LO" and mode in {"d", "v"}:
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)
diff --git a/precision_drawing_tools/pdt_design.py b/precision_drawing_tools/pdt_design.py
index 8a5e1234..f1505353 100644
--- a/precision_drawing_tools/pdt_design.py
+++ b/precision_drawing_tools/pdt_design.py
@@ -299,6 +299,82 @@ class PDT_OT_PlacementDis(Operator):
return {"FINISHED"}
+class PDT_OT_PlacementView(Operator):
+ """Use Distance Input for View Normal Axis Operations"""
+
+ bl_idname = "pdt.view_axis"
+ bl_label = "View Normal Axis Mode"
+ bl_options = {"REGISTER", "UNDO"}
+
+ def execute(self, context):
+ """Manipulates Geometry, or Objects by View Normal Axis Offset (Increment).
+
+ Note:
+ - Reads pg.operation from Operation Mode Selector as 'operation'
+ - Reads pg.select, pg.plane, pg.cartesian_coords scene variables to:
+ -- set position of CUrsor (CU)
+ -- set position of Pivot Point (PP)
+ -- MoVe geometry/objects (MV)
+ -- Extrude Vertices (EV)
+ -- Split Edges (SE)
+ -- add a New Vertex (NV)
+ -- Duplicate Geometry (DG)
+ -- Extrude Geometry (EG)
+
+ Invalid Options result in self.report Error.
+
+ Args:
+ context: Blender bpy.context instance.
+
+ Returns:
+ Status Set.
+ """
+
+ pg = context.scene.pdt_pg
+ operation = pg.operation
+ decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
+
+ if operation == "CU":
+ # Cursor
+ pg.command = (
+ f"cv{str(round(pg.distance, decimal_places))}"
+ )
+ elif operation == "PP":
+ # Pivot Point
+ pg.command = (
+ f"pv{str(round(pg.distance, decimal_places))}"
+ )
+ elif operation == "MV":
+ # Move Entities
+ pg.command = (
+ f"gv{str(round(pg.distance, decimal_places))}"
+ )
+ elif operation == "NV":
+ # New Vertex
+ pg.command = (
+ f"nv{str(round(pg.distance, decimal_places))}"
+ )
+ elif operation == "EV":
+ # Extrue Vertices
+ pg.command = (
+ f"vv{str(round(pg.distance, decimal_places))}"
+ )
+ elif operation == "DG":
+ # Duplicate Entities
+ pg.command = (
+ f"dv{str(round(pg.distance, decimal_places))}"
+ )
+ elif operation == "EG":
+ # Extrue Geometry
+ pg.command = (
+ f"ev{str(round(pg.distance, decimal_places))}"
+ )
+ else:
+ error_message = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_DEL}"
+ self.report({"ERROR"}, error_message)
+ return {"FINISHED"}
+
+
class PDT_OT_PlacementPer(Operator):
"""Use Percentage Placement"""
@@ -703,3 +779,9 @@ class PDT_OT_Taper(Operator):
pg = context.scene.pdt_pg
pg.command = f"tap"
return {"FINISHED"}
+
+#class PDT_Extrude_Modal(Operator):
+# """Extrude Modal Plane Along Normal Axis"""
+# bl_idname = "pdt.extrude_modal"
+# bl_label = "Extrude Modal Normal"
+# bl_options = {"REGISTER", "UNDO"}
diff --git a/precision_drawing_tools/pdt_menus.py b/precision_drawing_tools/pdt_menus.py
index be452f01..d7713700 100644
--- a/precision_drawing_tools/pdt_menus.py
+++ b/precision_drawing_tools/pdt_menus.py
@@ -62,7 +62,8 @@ from .pdt_msg_strings import (
PDT_LAB_TAPERAXES,
PDT_LAB_TOOLS,
PDT_LAB_USEVERTS,
- PDT_LAB_VARIABLES
+ PDT_LAB_VARIABLES,
+ PDT_LAB_VIEW
)
def ui_width():
@@ -148,6 +149,8 @@ class PDT_PT_PanelDesign(Panel):
row.prop(pdt_pg, "angle", text=PDT_LAB_ANGLEVALUE)
row = box.row()
row.operator("pdt.distance", icon="EMPTY_AXIS", text=f"{PDT_LAB_DIR} »")
+ row.operator("pdt.view_axis", icon="EMPTY_AXIS", text=f"{PDT_LAB_VIEW} »")
+ row = box.row()
row.prop(pdt_pg, "flip_angle", text=PDT_LAB_FLIPANGLE)
# ---------------------
diff --git a/precision_drawing_tools/pdt_msg_strings.py b/precision_drawing_tools/pdt_msg_strings.py
index 7d0cc2bc..a5eb3d99 100644
--- a/precision_drawing_tools/pdt_msg_strings.py
+++ b/precision_drawing_tools/pdt_msg_strings.py
@@ -80,6 +80,7 @@ PDT_LAB_PIVOTWIDTH = "" # Intentionally left blank
PDT_LAB_PIVOTALPHA = "" # Intentionally left blank
PDT_LAB_PIVOTLOC = "" # Intentionally left blank
PDT_LAB_PIVOTLOCH = "Location"
+PDT_LAB_VIEW = "View Normal Axis"
#
# Error Message
#