PDT: Rename more variables for readability
This commit is contained in:
parent
ff37747efc
commit
0e4dd304d6
|
@ -96,18 +96,18 @@ def vector_build(context, pg, obj, operation, values, num_values):
|
|||
|
||||
scene = context.scene
|
||||
plane = pg.plane
|
||||
flip_a = pg.flip_angle
|
||||
flip_p = pg.flip_percent
|
||||
flip_angle = pg.flip_angle
|
||||
flip_percent= pg.flip_percent
|
||||
|
||||
# Cartesian 3D coordinates
|
||||
if num_values == 3 and len(values) == 3:
|
||||
output_vector = Vector((float(values[0]), float(values[1]), float(values[2])))
|
||||
# Polar 2D coordinates
|
||||
elif num_values == 2 and len(values) == 2:
|
||||
output_vector = dis_ang(values, flip_a, plane, scene)
|
||||
output_vector = dis_ang(values, flip_angle, plane, scene)
|
||||
# Percentage of imaginary line between two 3D coordinates
|
||||
elif num_values == 1 and len(values) == 1:
|
||||
output_vector = get_percent(obj, flip_p, float(values[0]), operation, scene)
|
||||
output_vector = get_percent(obj, flip_percent, float(values[0]), operation, scene)
|
||||
else:
|
||||
if num_values == 3:
|
||||
pg.error = PDT_ERR_BAD3VALS
|
||||
|
@ -143,7 +143,7 @@ def placement_normal(context, operation):
|
|||
|
||||
scene = context.scene
|
||||
pg = scene.pdt_pg
|
||||
ext_a = pg.extend
|
||||
extend_all = pg.extend
|
||||
obj = context.view_layer.objects.active
|
||||
|
||||
if obj.mode == "EDIT":
|
||||
|
@ -186,7 +186,7 @@ def placement_normal(context, operation):
|
|||
pg.pivot_loc = vector_delta
|
||||
elif operation == "G":
|
||||
if obj.mode == "EDIT":
|
||||
if ext_a:
|
||||
if extend_all :
|
||||
for v in [v for v in bm.verts if v.select]:
|
||||
v.co = vector_delta
|
||||
bm.select_history.clear()
|
||||
|
@ -212,7 +212,7 @@ def placement_normal(context, operation):
|
|||
elif operation == "V" and obj.mode == "EDIT":
|
||||
vector_new = vector_delta
|
||||
vertex_new = bm.verts.new(vector_new)
|
||||
if ext_a:
|
||||
if extend_all :
|
||||
for v in [v for v in bm.verts if v.select]:
|
||||
bm.edges.new([v, vertex_new])
|
||||
else:
|
||||
|
@ -249,7 +249,7 @@ def placement_arc_centre(context, operation):
|
|||
|
||||
scene = context.scene
|
||||
pg = scene.pdt_pg
|
||||
ext_a = pg.extend
|
||||
extend_all = pg.extend
|
||||
obj = context.view_layer.objects.active
|
||||
|
||||
if obj.mode == "EDIT":
|
||||
|
@ -288,7 +288,7 @@ def placement_arc_centre(context, operation):
|
|||
bm.select_history.clear()
|
||||
vertex_new.select_set(True)
|
||||
elif operation == "G":
|
||||
if ext_a:
|
||||
if extend_all :
|
||||
for v in [v for v in bm.verts if v.select]:
|
||||
v.co = vector_delta
|
||||
bm.select_history.clear()
|
||||
|
@ -299,7 +299,7 @@ def placement_arc_centre(context, operation):
|
|||
bmesh.update_edit_mesh(obj.data)
|
||||
elif operation == "V":
|
||||
vertex_new = bm.verts.new(vector_delta)
|
||||
if ext_a:
|
||||
if extend_all :
|
||||
for v in [v for v in bm.verts if v.select]:
|
||||
bm.edges.new([v, vertex_new])
|
||||
v.select_set(False)
|
||||
|
@ -368,7 +368,7 @@ def placement_intersect(context, operation):
|
|||
obj_loc = obj.matrix_world.decompose()[0]
|
||||
bm = bmesh.from_edit_mesh(obj.data)
|
||||
edges = [e for e in bm.edges if e.select]
|
||||
ext_a = pg.extend
|
||||
extend_all = pg.extend
|
||||
|
||||
if len(edges) == 2:
|
||||
vertex_a = edges[0].verts[0]
|
||||
|
@ -415,43 +415,43 @@ def placement_intersect(context, operation):
|
|||
bm.select_history.clear()
|
||||
elif operation in {"G", "V"}:
|
||||
vertex_new = None
|
||||
proc = False
|
||||
process = False
|
||||
|
||||
if (vertex_a.co - vector_delta).length < (vertex_b.co - vector_delta).length:
|
||||
if operation == "G":
|
||||
vertex_a.co = vector_delta
|
||||
proc = True
|
||||
process = True
|
||||
else:
|
||||
vertex_new = bm.verts.new(vector_delta)
|
||||
bm.edges.new([vertex_a, vertex_new])
|
||||
proc = True
|
||||
process = True
|
||||
else:
|
||||
if operation == "G" and ext_a:
|
||||
if operation == "G" and extend_all :
|
||||
vertex_b.co = vector_delta
|
||||
elif operation == "V" and ext_a:
|
||||
elif operation == "V" and extend_all :
|
||||
vertex_new = bm.verts.new(vector_delta)
|
||||
bm.edges.new([vertex_b, vertex_new])
|
||||
else:
|
||||
return
|
||||
|
||||
if (vertex_c.co - vector_delta).length < (vertex_d.co - vector_delta).length:
|
||||
if operation == "G" and ext_a:
|
||||
if operation == "G" and extend_all :
|
||||
vertex_c.co = vector_delta
|
||||
elif operation == "V" and ext_a:
|
||||
elif operation == "V" and extend_all :
|
||||
bm.edges.new([vertex_c, vertex_new])
|
||||
else:
|
||||
return
|
||||
else:
|
||||
if operation == "G" and ext_a:
|
||||
if operation == "G" and extend_all :
|
||||
vertex_d.co = vector_delta
|
||||
elif operation == "V" and ext_a:
|
||||
elif operation == "V" and extend_all :
|
||||
bm.edges.new([vertex_d, vertex_new])
|
||||
else:
|
||||
return
|
||||
bm.select_history.clear()
|
||||
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
|
||||
|
||||
if not proc and not ext_a:
|
||||
if not process and not extend_all :
|
||||
pg.error = PDT_ERR_INT_NO_ALL
|
||||
context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
|
||||
bmesh.update_edit_mesh(obj.data)
|
||||
|
@ -575,7 +575,7 @@ def set_angle_distance_two(context):
|
|||
scene = context.scene
|
||||
pg = scene.pdt_pg
|
||||
plane = pg.plane
|
||||
flip_a = pg.flip_angle
|
||||
flip_angle = pg.flip_angle
|
||||
obj = context.view_layer.objects.active
|
||||
if obj is None:
|
||||
pg.error = PDT_ERR_NO_ACT_OBJ
|
||||
|
@ -619,23 +619,23 @@ def set_angle_distance_two(context):
|
|||
v0 = np.array([vector_a[a1] + 1, vector_a[a2]]) - np.array([vector_a[a1], vector_a[a2]])
|
||||
v1 = np.array([vector_b[a1], vector_b[a2]]) - np.array([vector_a[a1], vector_a[a2]])
|
||||
ang = np.rad2deg(np.arctan2(np.linalg.det([v0, v1]), np.dot(v0, v1)))
|
||||
val_round = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
if flip_a:
|
||||
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
if flip_angle:
|
||||
if ang > 0:
|
||||
pg.angle = round(ang - 180, val_round)
|
||||
pg.angle = round(ang - 180, decimal_places)
|
||||
else:
|
||||
pg.angle = round(ang - 180, val_round)
|
||||
pg.angle = round(ang - 180, decimal_places)
|
||||
else:
|
||||
pg.angle = round(ang, val_round)
|
||||
pg.angle = round(ang, decimal_places)
|
||||
if plane == "LO":
|
||||
pg.distance = round(sqrt(
|
||||
(vector_a.x - vector_b.x) ** 2 +
|
||||
(vector_a.y - vector_b.y) ** 2), val_round)
|
||||
(vector_a.y - vector_b.y) ** 2), decimal_places)
|
||||
else:
|
||||
pg.distance = round(sqrt(
|
||||
(vector_a[a1] - vector_b[a1]) ** 2 +
|
||||
(vector_a[a2] - vector_b[a2]) ** 2), val_round)
|
||||
pg.cartesian_coords = Vector(([round(i, val_round) for i in vector_b - vector_a]))
|
||||
(vector_a[a2] - vector_b[a2]) ** 2), decimal_places)
|
||||
pg.cartesian_coords = Vector(([round(i, decimal_places) for i in vector_b - vector_a]))
|
||||
|
||||
|
||||
def set_angle_distance_three(context):
|
||||
|
@ -653,7 +653,7 @@ def set_angle_distance_three(context):
|
|||
"""
|
||||
|
||||
pg = context.scene.pdt_pg
|
||||
flip_a = pg.flip_angle
|
||||
flip_angle = pg.flip_angle
|
||||
obj = context.view_layer.objects.active
|
||||
if obj is None:
|
||||
pg.error = PDT_ERR_NO_ACT_OBJ
|
||||
|
@ -695,16 +695,16 @@ def set_angle_distance_three(context):
|
|||
)
|
||||
angle_cosine = np.dot(ba, bc) / (np.linalg.norm(ba) * np.linalg.norm(bc))
|
||||
ang = np.degrees(np.arccos(angle_cosine))
|
||||
val_round = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
if flip_a:
|
||||
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
if flip_angle:
|
||||
if ang > 0:
|
||||
pg.angle = round(ang - 180, val_round)
|
||||
pg.angle = round(ang - 180, decimal_places)
|
||||
else:
|
||||
pg.angle = round(ang - 180, val_round)
|
||||
pg.angle = round(ang - 180, decimal_places)
|
||||
else:
|
||||
pg.angle = round(ang, val_round)
|
||||
pg.distance = round((vector_a - vector_b).length, val_round)
|
||||
pg.cartesian_coords = Vector(([round(i, val_round) for i in vector_b - vector_a]))
|
||||
pg.angle = round(ang, decimal_places)
|
||||
pg.distance = round((vector_a - vector_b).length, decimal_places)
|
||||
pg.cartesian_coords = Vector(([round(i, decimal_places) for i in vector_b - vector_a]))
|
||||
|
||||
|
||||
def origin_to_cursor(context):
|
||||
|
|
|
@ -142,9 +142,9 @@ def enumlist_objects(self, context):
|
|||
if path.is_file() and ".blend" in str(path):
|
||||
with bpy.data.libraries.load(str(path)) as (data_from, _):
|
||||
if len(pg.object_search_string) == 0:
|
||||
object_names = [ob for ob in data_from.objects]
|
||||
object_names = [obj for obj in data_from.objects]
|
||||
else:
|
||||
object_names = [ob for ob in data_from.objects if pg.object_search_string in ob]
|
||||
object_names = [obj for obj in data_from.objects if pg.object_search_string in obj]
|
||||
for object_name in object_names:
|
||||
_pdt_obj_items.append((object_name, object_name, ""))
|
||||
else:
|
||||
|
@ -174,10 +174,10 @@ def enumlist_collections(self, context):
|
|||
if path.is_file() and ".blend" in str(path):
|
||||
with bpy.data.libraries.load(str(path)) as (data_from, _):
|
||||
if len(pg.collection_search_string) == 0:
|
||||
object_names = [ob for ob in data_from.collections]
|
||||
object_names = [obj for obj in data_from.collections]
|
||||
else:
|
||||
object_names = [
|
||||
ob for ob in data_from.collections if pg.collection_search_string in ob
|
||||
obj for obj in data_from.collections if pg.collection_search_string in obj
|
||||
]
|
||||
for object_name in object_names:
|
||||
_pdt_col_items.append((object_name, object_name, ""))
|
||||
|
@ -208,9 +208,11 @@ def enumlist_materials(self, context):
|
|||
if path.is_file() and ".blend" in str(path):
|
||||
with bpy.data.libraries.load(str(path)) as (data_from, _):
|
||||
if len(pg.material_search_string) == 0:
|
||||
object_names = [ob for ob in data_from.materials]
|
||||
object_names = [obj for obj in data_from.materials]
|
||||
else:
|
||||
object_names = [ob for ob in data_from.materials if pg.material_search_string in ob]
|
||||
object_names = [
|
||||
obj for obj in data_from.materials if pg.material_search_string in obj
|
||||
]
|
||||
for object_name in object_names:
|
||||
_pdt_mat_items.append((object_name, object_name, ""))
|
||||
else:
|
||||
|
|
|
@ -166,10 +166,10 @@ def vertex_indices_from_edges_tuple(bm, edge_tuple):
|
|||
The vertex indices of edge_tuple.
|
||||
"""
|
||||
|
||||
def k(ind_v, ind_w):
|
||||
def find_verts(ind_v, ind_w):
|
||||
return bm.edges[edge_tuple[ind_v]].verts[ind_w].index
|
||||
|
||||
return [k(i >> 1, i % 2) for i in range(4)]
|
||||
return [find_verts(i >> 1, i % 2) for i in range(4)]
|
||||
|
||||
|
||||
def get_vert_indices_from_bmedges(edges):
|
||||
|
|
|
@ -370,22 +370,22 @@ def command_maths(context, mode, pg, expression, output_target):
|
|||
context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
|
||||
raise PDT_MathsError
|
||||
|
||||
val_round = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
if output_target == "x":
|
||||
pg.cartesian_coords.x = round(maths_result, val_round)
|
||||
pg.cartesian_coords.x = round(maths_result, decimal_places)
|
||||
elif output_target == "y":
|
||||
pg.cartesian_coords.y = round(maths_result, val_round)
|
||||
pg.cartesian_coords.y = round(maths_result, decimal_places)
|
||||
elif output_target == "z":
|
||||
pg.cartesian_coords.z = round(maths_result, val_round)
|
||||
pg.cartesian_coords.z = round(maths_result, decimal_places)
|
||||
elif output_target == "d":
|
||||
pg.distance = round(maths_result, val_round)
|
||||
pg.distance = round(maths_result, decimal_places)
|
||||
elif output_target == "a":
|
||||
pg.angle = round(maths_result, val_round)
|
||||
pg.angle = round(maths_result, decimal_places)
|
||||
elif output_target == "p":
|
||||
pg.percent = round(maths_result, val_round)
|
||||
pg.percent = round(maths_result, decimal_places)
|
||||
else:
|
||||
# Must be "o"
|
||||
pg.maths_output = round(maths_result, val_round)
|
||||
pg.maths_output = round(maths_result, decimal_places)
|
||||
|
||||
|
||||
def command_parse(context):
|
||||
|
@ -414,8 +414,8 @@ def command_parse(context):
|
|||
values[ind] = "0.0"
|
||||
ind = ind + 1
|
||||
# Apply System Rounding
|
||||
val_round = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
values_out = [str(round(float(v), val_round)) for v in values]
|
||||
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
values_out = [str(round(float(v), decimal_places)) for v in values]
|
||||
|
||||
bm, good = obj_check(obj, scene, operation)
|
||||
if good:
|
||||
|
@ -474,9 +474,6 @@ def move_cursor_pivot(context, pg, operation, mode, obj, verts, values):
|
|||
except:
|
||||
raise PDT_InvalidVector
|
||||
|
||||
if vector_delta is None:
|
||||
raise PDT_InvalidVector
|
||||
|
||||
scene = context.scene
|
||||
mode_sel = pg.select
|
||||
obj_loc = obj.matrix_world.decompose()[0]
|
||||
|
@ -787,14 +784,14 @@ def extrude_vertices(context, pg, operation, mode, obj, obj_loc, bm, verts, valu
|
|||
new_vertex.select_set(True)
|
||||
# Percent Options
|
||||
elif mode == "p":
|
||||
ext_a = pg.extend
|
||||
extend_all = pg.extend
|
||||
try:
|
||||
vector_delta = vector_build(context, pg, obj, operation, values, 1)
|
||||
except:
|
||||
raise PDT_InvalidVector
|
||||
verts = [v for v in bm.verts if v.select].copy()
|
||||
new_vertex = bm.verts.new(vector_delta)
|
||||
if ext_a:
|
||||
if extend_all :
|
||||
for v in [v for v in bm.verts if v.select]:
|
||||
bm.edges.new([v, new_vertex])
|
||||
v.select_set(False)
|
||||
|
|
|
@ -62,53 +62,53 @@ class PDT_OT_PlacementAbs(Operator):
|
|||
|
||||
pg = context.scene.pdt_pg
|
||||
operation = pg.operation
|
||||
val_round = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
|
||||
if operation == "CU":
|
||||
# Cursor
|
||||
pg.command = (
|
||||
f"ca{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"ca{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "PP":
|
||||
# Pivot Point
|
||||
pg.command = (
|
||||
f"pa{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"pa{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "MV":
|
||||
# Move Entities
|
||||
pg.command = (
|
||||
f"ga{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"ga{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "SE":
|
||||
# Split Edges
|
||||
pg.command = (
|
||||
f"sa{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"sa{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "NV":
|
||||
# New Vertex
|
||||
pg.command = (
|
||||
f"na{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"na{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "EV":
|
||||
# Extrude Vertices
|
||||
pg.command = (
|
||||
f"va{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"va{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
else:
|
||||
errmsg = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_ABS}"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_ABS}"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
@ -144,67 +144,67 @@ class PDT_OT_PlacementDelta(Operator):
|
|||
|
||||
pg = context.scene.pdt_pg
|
||||
operation = pg.operation
|
||||
val_round = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
|
||||
if operation == "CU":
|
||||
# Cursor
|
||||
pg.command = (
|
||||
f"cd{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"cd{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "PP":
|
||||
# Pivot Point
|
||||
pg.command = (
|
||||
f"pd{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"pd{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "MV":
|
||||
# Move Entities
|
||||
pg.command = (
|
||||
f"gd{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"gd{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "SE":
|
||||
# Split Edges
|
||||
pg.command = (
|
||||
f"sd{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"sd{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "NV":
|
||||
# New Vertex
|
||||
pg.command = (
|
||||
f"nd{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"nd{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "EV":
|
||||
# Extrue Vertices
|
||||
pg.command = (
|
||||
f"vd{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"vd{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "DG":
|
||||
# Duplicate Entities
|
||||
pg.command = (
|
||||
f"dd{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"dd{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
elif operation == "EG":
|
||||
# Extrue Geometry
|
||||
pg.command = (
|
||||
f"ed{str(round(pg.cartesian_coords.x, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.y, val_round))}"
|
||||
f",{str(round(pg.cartesian_coords.z, val_round))}"
|
||||
f"ed{str(round(pg.cartesian_coords.x, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.y, decimal_places))}"
|
||||
f",{str(round(pg.cartesian_coords.z, decimal_places))}"
|
||||
)
|
||||
else:
|
||||
errmsg = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_DEL}"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_DEL}"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
@ -240,59 +240,59 @@ class PDT_OT_PlacementDis(Operator):
|
|||
|
||||
pg = context.scene.pdt_pg
|
||||
operation = pg.operation
|
||||
val_round = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
|
||||
if operation == "CU":
|
||||
# Cursor
|
||||
pg.command = (
|
||||
f"ci{str(round(pg.distance, val_round))}"
|
||||
f",{str(round(pg.angle, val_round))}"
|
||||
f"ci{str(round(pg.distance, decimal_places))}"
|
||||
f",{str(round(pg.angle, decimal_places))}"
|
||||
)
|
||||
elif operation == "PP":
|
||||
# Pivot Point
|
||||
pg.command = (
|
||||
f"pi{str(round(pg.distance, val_round))}"
|
||||
f",{str(round(pg.angle, val_round))}"
|
||||
f"pi{str(round(pg.distance, decimal_places))}"
|
||||
f",{str(round(pg.angle, decimal_places))}"
|
||||
)
|
||||
elif operation == "MV":
|
||||
# Move Entities
|
||||
pg.command = (
|
||||
f"gi{str(round(pg.distance, val_round))}"
|
||||
f",{str(round(pg.angle, val_round))}"
|
||||
f"gi{str(round(pg.distance, decimal_places))}"
|
||||
f",{str(round(pg.angle, decimal_places))}"
|
||||
)
|
||||
elif operation == "SE":
|
||||
# Split Edges
|
||||
pg.command = (
|
||||
f"si{str(round(pg.distance, val_round))}"
|
||||
f",{str(round(pg.angle, val_round))}"
|
||||
f"si{str(round(pg.distance, decimal_places))}"
|
||||
f",{str(round(pg.angle, decimal_places))}"
|
||||
)
|
||||
elif operation == "NV":
|
||||
# New Vertex
|
||||
pg.command = (
|
||||
f"ni{str(round(pg.distance, val_round))}"
|
||||
f",{str(round(pg.angle, val_round))}"
|
||||
f"ni{str(round(pg.distance, decimal_places))}"
|
||||
f",{str(round(pg.angle, decimal_places))}"
|
||||
)
|
||||
elif operation == "EV":
|
||||
# Extrude Vertices
|
||||
pg.command = (
|
||||
f"vi{str(round(pg.distance, val_round))}"
|
||||
f",{str(round(pg.angle, val_round))}"
|
||||
f"vi{str(round(pg.distance, decimal_places))}"
|
||||
f",{str(round(pg.angle, decimal_places))}"
|
||||
)
|
||||
elif operation == "DG":
|
||||
# Duplicate Geometry
|
||||
pg.command = (
|
||||
f"di{str(round(pg.distance, val_round))}"
|
||||
f",{str(round(pg.angle, val_round))}"
|
||||
f"di{str(round(pg.distance, decimal_places))}"
|
||||
f",{str(round(pg.angle, decimal_places))}"
|
||||
)
|
||||
elif operation == "EG":
|
||||
# Extrude Geometry
|
||||
pg.command = (
|
||||
f"ei{str(round(pg.distance, val_round))}"
|
||||
f",{str(round(pg.angle, val_round))}"
|
||||
f"ei{str(round(pg.distance, decimal_places))}"
|
||||
f",{str(round(pg.angle, decimal_places))}"
|
||||
)
|
||||
else:
|
||||
errmsg = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_DIR}"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_DIR}"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
@ -326,29 +326,29 @@ class PDT_OT_PlacementPer(Operator):
|
|||
|
||||
pg = context.scene.pdt_pg
|
||||
operation = pg.operation
|
||||
val_round = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
|
||||
if operation == "CU":
|
||||
# Cursor
|
||||
pg.command = f"cp{str(round(pg.percent, val_round))}"
|
||||
pg.command = f"cp{str(round(pg.percent, decimal_places))}"
|
||||
elif operation == "PP":
|
||||
# Pivot Point
|
||||
pg.command = f"pp{str(round(pg.percent, val_round))}"
|
||||
pg.command = f"pp{str(round(pg.percent, decimal_places))}"
|
||||
elif operation == "MV":
|
||||
# Move Entities
|
||||
pg.command = f"gp{str(round(pg.percent, val_round))}"
|
||||
pg.command = f"gp{str(round(pg.percent, decimal_places))}"
|
||||
elif operation == "SE":
|
||||
# Split Edges
|
||||
pg.command = f"sp{str(round(pg.percent, val_round))}"
|
||||
pg.command = f"sp{str(round(pg.percent, decimal_places))}"
|
||||
elif operation == "NV":
|
||||
# New Vertex
|
||||
pg.command = f"np{str(round(pg.percent, val_round))}"
|
||||
pg.command = f"np{str(round(pg.percent, decimal_places))}"
|
||||
elif operation == "EV":
|
||||
# Extrude Vertices
|
||||
pg.command = f"vp{str(round(pg.percent, val_round))}"
|
||||
pg.command = f"vp{str(round(pg.percent, decimal_places))}"
|
||||
else:
|
||||
errmsg = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_PERCENT}"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_PERCENT}"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
@ -395,8 +395,8 @@ class PDT_OT_PlacementNormal(Operator):
|
|||
elif operation == "NV":
|
||||
pg.command = f"nnml"
|
||||
else:
|
||||
errmsg = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_INTERSECT}"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_INTERSECT}"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
@ -439,8 +439,8 @@ class PDT_OT_PlacementCen(Operator):
|
|||
elif operation == "NV":
|
||||
pg.command = f"ncen"
|
||||
else:
|
||||
errmsg = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_INTERSECT}"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_INTERSECT}"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
@ -486,8 +486,8 @@ class PDT_OT_PlacementInt(Operator):
|
|||
elif operation == "NV":
|
||||
pg.command = f"nint"
|
||||
else:
|
||||
errmsg = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_INTERSECT}"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_INTERSECT}"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
@ -556,24 +556,24 @@ class PDT_OT_Fillet(Operator):
|
|||
"""
|
||||
|
||||
pg = context.scene.pdt_pg
|
||||
val_round = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
|
||||
if pg.fillet_intersect:
|
||||
pg.command = (
|
||||
f"fi{str(round(pg.fillet_radius, val_round))}"
|
||||
f",{str(round(pg.fillet_segments, val_round))}"
|
||||
f",{str(round(pg.fillet_profile, val_round))}"
|
||||
f"fi{str(round(pg.fillet_radius, decimal_places))}"
|
||||
f",{str(round(pg.fillet_segments, decimal_places))}"
|
||||
f",{str(round(pg.fillet_profile, decimal_places))}"
|
||||
)
|
||||
elif pg.fillet_vertices_only:
|
||||
pg.command = (
|
||||
f"fv{str(round(pg.fillet_radius, val_round))}"
|
||||
f",{str(round(pg.fillet_segments, val_round))}"
|
||||
f",{str(round(pg.fillet_profile, val_round))}"
|
||||
f"fv{str(round(pg.fillet_radius, decimal_places))}"
|
||||
f",{str(round(pg.fillet_segments, decimal_places))}"
|
||||
f",{str(round(pg.fillet_profile, decimal_places))}"
|
||||
)
|
||||
else:
|
||||
pg.command = (
|
||||
f"fe{str(round(pg.fillet_radius, val_round))}"
|
||||
f",{str(round(pg.fillet_segments, val_round))}"
|
||||
f",{str(round(pg.fillet_profile, val_round))}"
|
||||
f"fe{str(round(pg.fillet_radius, decimal_places))}"
|
||||
f",{str(round(pg.fillet_segments, decimal_places))}"
|
||||
f",{str(round(pg.fillet_profile, decimal_places))}"
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
|
|
@ -405,7 +405,7 @@ def intersection(vertex_a, vertex_b, vertex_c, vertex_d, plane):
|
|||
return vector_delta, True
|
||||
|
||||
|
||||
def get_percent(obj, flip_p, per_v, data, scene):
|
||||
def get_percent(obj, flip_percent, per_v, data, scene):
|
||||
"""Calculates a Percentage Distance between 2 Vectors.
|
||||
|
||||
Calculates a point that lies a set percentage between two given points
|
||||
|
@ -416,7 +416,7 @@ def get_percent(obj, flip_p, per_v, data, scene):
|
|||
|
||||
Args:
|
||||
obj: The Object under consideration
|
||||
flip_p: Setting this to True measures the percentage starting from the second vector
|
||||
flip_percent: Setting this to True measures the percentage starting from the second vector
|
||||
per_v: Percentage Input Value
|
||||
data: pg.flip, pg.percent scene variables & Operational Mode
|
||||
scene: Context Scene
|
||||
|
@ -466,7 +466,7 @@ def get_percent(obj, flip_p, per_v, data, scene):
|
|||
coord_c = coord_b - coord_a
|
||||
coord_d = np.array([0, 0, 0])
|
||||
_per_v = per_v
|
||||
if (flip_p and data != "MV") or data == "MV":
|
||||
if (flip_percent and data != "MV") or data == "MV":
|
||||
_per_v = 100 - per_v
|
||||
coord_out = (coord_d+coord_c) * (_per_v / 100) + coord_a
|
||||
return Vector((coord_out[0], coord_out[1], coord_out[2]))
|
||||
|
@ -683,8 +683,8 @@ def scale_set(self, context):
|
|||
|
||||
scene = context.scene
|
||||
pg = scene.pdt_pg
|
||||
sys_dis = pg.distance
|
||||
scale_dis = pg.pivot_dis
|
||||
if scale_dis > 0:
|
||||
scale_fac = scale_dis / sys_dis
|
||||
pg.pivot_scale = Vector((scale_fac, scale_fac, scale_fac))
|
||||
sys_distance = pg.distance
|
||||
scale_distance = pg.pivot_dis
|
||||
if scale_distance > 0:
|
||||
scale_factor = scale_distance / sys_distance
|
||||
pg.pivot_scale = Vector((scale_factor, scale_factor, scale_factor))
|
||||
|
|
|
@ -131,8 +131,8 @@ class PDT_OT_Append(Operator):
|
|||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
errmsg = PDT_ERR_NO_LIBRARY
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = PDT_ERR_NO_LIBRARY
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
@ -191,6 +191,6 @@ class PDT_OT_Link(Operator):
|
|||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
errmsg = PDT_ERR_NO_LIBRARY
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = PDT_ERR_NO_LIBRARY
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
|
|
|
@ -148,8 +148,8 @@ class PDT_OT_ViewPlaneRotate(Operator):
|
|||
self.report({"ERROR"}, PDT_ERR_NO_ACT_OBJ)
|
||||
return {"FINISHED"}
|
||||
if obj.mode != "EDIT":
|
||||
errmsg = f"{PDT_ERR_EDIT_MODE} {obj.mode})"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{PDT_ERR_EDIT_MODE} {obj.mode})"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
bm = bmesh.from_edit_mesh(obj.data)
|
||||
v1 = Vector((0, 0, 0))
|
||||
|
@ -203,8 +203,8 @@ class PDT_OT_ViewPlaneScale(Operator):
|
|||
self.report({"ERROR"}, PDT_ERR_NO_ACT_OBJ)
|
||||
return {"FINISHED"}
|
||||
if obj.mode != "EDIT":
|
||||
errmsg = f"{PDT_ERR_EDIT_MODE} {obj.mode})"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{PDT_ERR_EDIT_MODE} {obj.mode})"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
bm = bmesh.from_edit_mesh(obj.data)
|
||||
verts = verts = [v for v in bm.verts if v.select]
|
||||
|
@ -246,8 +246,8 @@ class PDT_OT_PivotToCursor(Operator):
|
|||
scene = context.scene
|
||||
pg = scene.pdt_pg
|
||||
old_cursor_loc = scene.cursor.location.copy()
|
||||
scene.cursor.location = old_cursor_loc
|
||||
pg.pivot_loc = scene.cursor.location
|
||||
scene.cursor.location = old_cursor_loc
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
@ -312,8 +312,8 @@ class PDT_OT_PivotSelected(Operator):
|
|||
self.report({"ERROR"}, PDT_ERR_NO_ACT_OBJ)
|
||||
return {"FINISHED"}
|
||||
if obj.mode != "EDIT":
|
||||
errmsg = f"{PDT_ERR_EDIT_MODE} {obj.mode})"
|
||||
self.report({"ERROR"}, errmsg)
|
||||
error_message = f"{PDT_ERR_EDIT_MODE} {obj.mode})"
|
||||
self.report({"ERROR"}, error_message)
|
||||
return {"FINISHED"}
|
||||
bm = bmesh.from_edit_mesh(obj.data)
|
||||
verts = verts = [v for v in bm.verts if v.select]
|
||||
|
|
Loading…
Reference in New Issue