diff options
author | Alan Odom <clockmender@icloud.com> | 2020-01-30 23:58:48 +0300 |
---|---|---|
committer | Rune Morling <ermo.blender.org@spammesenseless.net> | 2020-02-01 18:44:06 +0300 |
commit | 83ad65d377f9899f624277cc90dd838496f0e4f3 (patch) | |
tree | 821438aab8f31c36205abbde3fdc04bfc4824ef0 /precision_drawing_tools | |
parent | 0e4dd304d6e9a7368cbac785ae4128c426777beb (diff) |
PDT: Update Docstrings per Design Spec Document
Diffstat (limited to 'precision_drawing_tools')
-rw-r--r-- | precision_drawing_tools/pdt_bix.py | 10 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_cad_module.py | 46 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_command.py | 79 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_etof.py | 38 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_functions.py | 47 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_library.py | 2 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_msg_strings.py | 12 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_pivot_point.py | 60 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_view.py | 6 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_xall.py | 65 |
10 files changed, 308 insertions, 57 deletions
diff --git a/precision_drawing_tools/pdt_bix.py b/precision_drawing_tools/pdt_bix.py index f6b5cb66..ec9661d9 100644 --- a/precision_drawing_tools/pdt_bix.py +++ b/precision_drawing_tools/pdt_bix.py @@ -117,7 +117,15 @@ class PDT_OT_LineOnBisection(bpy.types.Operator): @classmethod def poll(cls, context): - """Only allow operation on a mesh object in EDIT mode.""" + """Only allow operation on a mesh object in EDIT mode. + + Args: + context: Blender bpy.context instance. + + Returns: + Boolean. + """ + obj = context.active_object if obj is None: return False diff --git a/precision_drawing_tools/pdt_cad_module.py b/precision_drawing_tools/pdt_cad_module.py index 880cf84d..74153a1d 100644 --- a/precision_drawing_tools/pdt_cad_module.py +++ b/precision_drawing_tools/pdt_cad_module.py @@ -33,7 +33,7 @@ def point_on_edge(point, edge): """Find Point on Edge. Args: - point: vector + point: vector edge: tuple containing 2 vectors. Returns: @@ -102,7 +102,7 @@ def test_coplanar(edge1, edge2): def closest_idx(intersect_point, edge): """Get Closest Vertex to input point. - If both points in e are equally far from intersect_point, then v1 is returned. + If both points in edge are equally far from intersect_point, then v1 is returned. Args: intersect_point: vector @@ -146,12 +146,30 @@ def closest_vector(intersect_point, edge): def coords_tuple_from_edge_idx(bm, idx): - """Return Tuple from Vertex.""" + """Return Tuple from Vertices. + + Args: + bm: Object Bmesh + idx: Index of chosen Edge + + Returns: + Tuple from Edge Vertices. + """ + return tuple(v.co for v in bm.edges[idx].verts) def vectors_from_indices(bm, raw_vert_indices): - """Return List of vectors from input indices.""" + """Return List of vectors from input Vertex Indices. + + Args: + bm: Object Bmesh + raw_vert_indices: List of Chosen Vertex Indices + + Returns: + List of Vertex coordinates. + """ + return [bm.verts[i].co for i in raw_vert_indices] @@ -163,7 +181,7 @@ def vertex_indices_from_edges_tuple(bm, edge_tuple): edge_tuple: contains 2 edge indices. Returns: - The vertex indices of edge_tuple. + The vertex indices of edge_tuple as an Integer list. """ def find_verts(ind_v, ind_w): @@ -176,11 +194,12 @@ def get_vert_indices_from_bmedges(edges): """Return List of Edges for evaluation. Args: - bmedges: a list of 2 bm edges + edges: a list of 2 bm edges Returns: The vertex indices of edge_tuple as a flat list. """ + temp_edges = [] debug(edges) for e in edges: @@ -190,7 +209,16 @@ def get_vert_indices_from_bmedges(edges): def num_edges_point_lies_on(intersect_point, edges): - """Returns the number of edges that a point lies on.""" + """Returns the number of edges that a point lies on. + + Args: + intersection_point: Vector describing 3D coordinates of intersection point + edges: List of Bmesh edges + + Returns: + Number of Intersecting Edges (Integer). + """ + res = [point_on_edge(intersect_point, edge) for edge in [edges[:2], edges[2:]]] return len([i for i in res if i]) @@ -199,12 +227,13 @@ def find_intersecting_edges(bm, intersect_point, idx1, idx2): """Find Intercecting Edges. Args: - intersect_point: Vector + intersect_point: Vector describing 3D coordinates of intersection point idx1, ix2: edge indices Returns: The list of edge indices where intersect_point is on those edges. """ + if not intersect_point: return [] idxs = [idx1, idx2] @@ -222,5 +251,6 @@ def vert_idxs_from_edge_idx(bm, idx): Returns: Vertex Indices of Edge. """ + edge = bm.edges[idx] return edge.verts[0].index, edge.verts[1].index diff --git a/precision_drawing_tools/pdt_command.py b/precision_drawing_tools/pdt_command.py index cfd0e666..77550957 100644 --- a/precision_drawing_tools/pdt_command.py +++ b/precision_drawing_tools/pdt_command.py @@ -304,7 +304,15 @@ def command_run(self, context): def pdt_help(self, context): - """Display PDT Command Line help in a pop-up.""" + """Display PDT Command Line help in a pop-up. + + Args: + Self: Itself as a reference for action + context: Blender bpy.context instance + + Returns: + Nothing. + """ label = self.layout.label label(text="Primary Letters (Available Secondary Letters):") label(text="") @@ -355,7 +363,10 @@ def command_maths(context, mode, pg, expression, output_target): Args: context: Blender bpy.context instance. - mode, pg, expression, output_target + mode: The Operation Mode, e.g. a for Absolute + pg: PDT Parameters Group - our variables + expression: The Maths component of the command input e.g. sqrt(56) + output_target: The output variable box on the UI Returns: Nothing. @@ -395,7 +406,12 @@ def command_parse(context): context: Blender bpy.context instance. Returns: - pg, values_out, obj, obj_loc, bm, verts. + pg: PDT Parameters Group - our variables + values_out: The Output Values as a list of numbers + obj: The Active Object + obj_loc: The objects location in 3D space + bm: The objects Bmesh + verts: The object's selected vertices, or selected history vertices. """ scene = context.scene pg = scene.pdt_pg @@ -448,7 +464,12 @@ def move_cursor_pivot(context, pg, operation, mode, obj, verts, values): Args: context: Blender bpy.context instance. - pg, operation, mode, obj, verts, values + pg: PDT Parameters Group - our variables + operation: The Operation e.g. Create New Vertex + mode: The Operation Mode, e.g. a for Absolute + obj: The Active Object + verts: The object's selected vertices, or selected history vertices + values: The paramters passed e.g. 1,4,3 for Catrtesan Coordinates Returns: Nothing. @@ -519,7 +540,13 @@ def move_entities(context, pg, operation, mode, obj, bm, verts, values): Args: context: Blender bpy.context instance. - pg, operation, mode, obj, bm, verts, values + pg: PDT Parameters Group - our variables + operation: The Operation e.g. Create New Vertex + mode: The Operation Mode, e.g. a for Absolute + obj: The Active Object + bm: The objects Bmesh + verts: The object's selected vertices, or selected history vertices + values: The paramters passed e.g. 1,4,3 for Catrtesan Coordinates Returns: Nothing. @@ -636,7 +663,14 @@ def split_edges(context, pg, operation, mode, obj, obj_loc, bm, values): Args: context: Blender bpy.context instance. - pg, operation, mode, obj, obj_loc, bm, verts, values + pg: PDT Parameters Group - our variables + operation: The Operation e.g. Create New Vertex + mode: The Operation Mode, e.g. a for Absolute + obj: The Active Object + obj_loc: The objects location in 3D space + bm: The objects Bmesh + verts: The object's selected vertices, or selected history vertices + values: The paramters passed e.g. 1,4,3 for Catrtesan Coordinates Returns: Nothing. @@ -733,7 +767,14 @@ def extrude_vertices(context, pg, operation, mode, obj, obj_loc, bm, verts, valu Args: context: Blender bpy.context instance. - pg, operation, mode, obj, onj_loc, bm, verts, values + pg: PDT Parameters Group - our variables + operation: The Operation e.g. Create New Vertex + mode: The Operation Mode, e.g. a for Absolute + obj: The Active Object + obj_loc: The objects location in 3D space + bm: The objects Bmesh + verts: The object's selected vertices, or selected history vertices + values: The paramters passed e.g. 1,4,3 for Catrtesan Coordinates Returns: Nothing. @@ -791,7 +832,7 @@ def extrude_vertices(context, pg, operation, mode, obj, obj_loc, bm, verts, valu raise PDT_InvalidVector verts = [v for v in bm.verts if v.select].copy() new_vertex = bm.verts.new(vector_delta) - if extend_all : + 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) @@ -808,7 +849,12 @@ def extrude_geometry(context, pg, operation, mode, obj, bm, values): Args: context: Blender bpy.context instance. - pg, operation, mode, obj, bm, verts, values + pg: PDT Parameters Group - our variables + operation: The Operation e.g. Create New Vertex + mode: The Operation Mode, e.g. a for Absolute + obj: The Active Object + bm: The objects Bmesh + values: The paramters passed e.g. 1,4,3 for Catrtesan Coordinates Returns: Nothing. @@ -856,7 +902,12 @@ def duplicate_geometry(context, pg, operation, mode, obj, bm, values): Args: context: Blender bpy.context instance. - pg, operation, mode, obj, bm, verts, values + pg: PDT Parameters Group - our variables + operation: The Operation e.g. Create New Vertex + mode: The Operation Mode, e.g. a for Absolute + obj: The Active Object + bm: The objects Bmesh + values: The paramters passed e.g. 1,4,3 for Catrtesan Coordinates Returns: Nothing. @@ -904,7 +955,13 @@ def fillet_geometry(context, pg, mode, obj, bm, verts, values): Args: context: Blender bpy.context instance. - pg, operation, mode, obj, bm, verts, values + pg: PDT Parameters Group - our variables + operation: The Operation e.g. Create New Vertex + mode: The Operation Mode, e.g. a for Absolute + obj: The Active Object + bm: The objects Bmesh + verts: The object's selected vertices, or selected history vertices + values: The paramters passed e.g. 1,4,3 for Catrtesan Coordinates Returns: Nothing. diff --git a/precision_drawing_tools/pdt_etof.py b/precision_drawing_tools/pdt_etof.py index 5a7b0985..2e9f8487 100644 --- a/precision_drawing_tools/pdt_etof.py +++ b/precision_drawing_tools/pdt_etof.py @@ -35,14 +35,30 @@ from .pdt_functions import oops def failure_message(context): - """Warn to the user to select 1 edge and 1 face.""" + """Warn to the user to select 1 edge and 1 face. + + Args: + context: Blender bpy.context instance. + + Returns: + Nothing. + """ + pg = context.scene.pdt_pg pg.error = f"Select One Face and One Edge" context.window_manager.popup_menu(oops, title="Error", icon="ERROR") def failure_message_on_plane(context): - """Report an informative error message in a popup.""" + """Report an informative error message in a popup. + + Args: + context: Blender bpy.context instance. + + Returns: + Nothing. + """ + pg = context.scene.pdt_pg pg.error = f"{PDT_ERR_NOINT}" context.window_manager.popup_menu(oops, title="Error", icon="ERROR") @@ -51,10 +67,11 @@ def extend_vertex(context): """Computes Edge Extension to Face. Args: - None + context: Blender bpy.context instance. Returns: - Nothing.""" + Nothing. + """ obj = bpy.context.edit_object pg = context.scene.pdt_pg @@ -116,7 +133,15 @@ class PDT_OT_EdgeToFace(bpy.types.Operator): @classmethod def poll(cls, context): - """Only allow this to work if a mesh is selected in EDIT mode.""" + """Only allow this to work if a mesh is selected in EDIT mode. + + Args: + context: Blender bpy.context instance. + + Returns: + Boolean. + """ + obj = context.object if obj is None: return False @@ -129,7 +154,8 @@ class PDT_OT_EdgeToFace(bpy.types.Operator): context: Blender bpy.context instance. Returns: - Status Set.""" + Status Set. + """ pg = context.scene.pdt_pg pg.command = f"etf" diff --git a/precision_drawing_tools/pdt_functions.py b/precision_drawing_tools/pdt_functions.py index dec3b972..5ce19f0a 100644 --- a/precision_drawing_tools/pdt_functions.py +++ b/precision_drawing_tools/pdt_functions.py @@ -48,6 +48,13 @@ def debug(msg, prefix=""): The printed message will be of the form: {prefix}{caller file name:line number}| {msg} + + Args: + msg: Incomming message to display + prefix: Always Blank + + Returns: + Nothing. """ pdt_debug = bpy.context.preferences.addons[__package__].preferences.debug @@ -55,7 +62,14 @@ def debug(msg, prefix=""): import traceback def extract_filename(fullpath): - """Return only the filename part of fullpath (excluding its path).""" + """Return only the filename part of fullpath (excluding its path). + + Args: + fullpath: Filename's full path + + Returns: + filename. + """ # Expected to end up being a string containing only the filename # (i.e. excluding its preceding '/' separated path) filename = fullpath.split('/')[-1] @@ -83,6 +97,9 @@ def oops(self, context): Note: Uses pg.error scene variable + + Returns: + Nothing. """ scene = context.scene @@ -265,8 +282,8 @@ def view_dir(dis_v, ang_v): Angles are Converts to Radians from degrees. Args: - dis_v: Scene distance - ang_v: Scene angle + dis_v: Scene PDT distance + ang_v: Scene PDT angle Returns: World Vector. @@ -315,8 +332,8 @@ def arc_centre(vector_a, vector_b, vector_c): Args: vector_a: Active vector location - vector_b: Other vector location - vector_d: Last vector location + vector_b: Second vector location + vector_c: Third vector location Returns: Vector representing Arc Centre and Float representing Arc Radius. @@ -353,10 +370,11 @@ def intersection(vertex_a, vertex_b, vertex_c, vertex_d, plane): whether the lines are convergent using standard Numpy Routines Args: vertex_a: Active vector location of first line - vertex_b: Other vector location of first line - vertex_d: Last vector location of 2nd line - vertex_c: First vector location of 2nd line + vertex_b: Second vector location of first line + vertex_c: Third vector location of 2nd line + vertex_d: Fourth vector location of 2nd line plane: Working Plane 4 Vector Locations representing 2 lines and Working Plane + Returns: Intersection Vector and Boolean for convergent state. """ @@ -472,20 +490,21 @@ def get_percent(obj, flip_percent, per_v, data, scene): return Vector((coord_out[0], coord_out[1], coord_out[2])) -def obj_check(obj, scene, operator): +def obj_check(obj, scene, operation): """Check Object & Selection Validity. Args: obj: Active Object scene: Active Scene - operator: Operation to check + operation: The Operation e.g. Create New Vertex Returns: - Object Bmesh and Validity Boolean. + Object Bmesh + Validity Boolean. """ pg = scene.pdt_pg - _operator = operator.upper() + _operation = operation.upper() if obj is None: pg.error = PDT_ERR_NO_ACT_OBJ @@ -493,7 +512,7 @@ def obj_check(obj, scene, operator): return None, False if obj.mode == "EDIT": bm = bmesh.from_edit_mesh(obj.data) - if _operator == "S": + if _operation == "S": if len(bm.edges) < 1: pg.error = f"{PDT_ERR_SEL_1_EDGEM} {len(bm.edges)})" bpy.context.window_manager.popup_menu(oops, title="Error", icon="ERROR") @@ -501,7 +520,7 @@ def obj_check(obj, scene, operator): return bm, True if len(bm.select_history) >= 1: vector_a = None - if _operator not in {"D", "E", "F", "G", "N", "S"}: + if _operation not in {"D", "E", "F", "G", "N", "S"}: vector_a = check_selection(1, bm, obj) else: verts = [v for v in bm.verts if v.select] diff --git a/precision_drawing_tools/pdt_library.py b/precision_drawing_tools/pdt_library.py index 0b57ed18..555b57d3 100644 --- a/precision_drawing_tools/pdt_library.py +++ b/precision_drawing_tools/pdt_library.py @@ -149,7 +149,7 @@ class PDT_OT_Link(Operator): Linked Objects are placed at Cursor Location Args: - context + context: Blender bpy.context instance. Notes: Uses pg.lib_objects, pg.lib_collections & pg.lib_materials diff --git a/precision_drawing_tools/pdt_msg_strings.py b/precision_drawing_tools/pdt_msg_strings.py index a9246fce..cf586d56 100644 --- a/precision_drawing_tools/pdt_msg_strings.py +++ b/precision_drawing_tools/pdt_msg_strings.py @@ -28,6 +28,18 @@ # # Menu Labels # +"""This file contains all the Message Strings. + + These strings are called by various programmes in PDT, + they can be set to suit individual User requirements. + +Args: + None + +Returns: + None +""" + PDT_LAB_ABS = "Absolute" # "Global" PDT_LAB_DEL = "Delta" # "Relative" PDT_LAB_DIR = "Direction" # "Polar" diff --git a/precision_drawing_tools/pdt_pivot_point.py b/precision_drawing_tools/pdt_pivot_point.py index 9b66ae2e..660a7a99 100644 --- a/precision_drawing_tools/pdt_pivot_point.py +++ b/precision_drawing_tools/pdt_pivot_point.py @@ -118,7 +118,15 @@ class PDT_OT_ViewPlaneRotate(Operator): @classmethod def poll(cls, context): - """Check Onject Status.""" + """Check Object Status. + + Args: + context: Blender bpy.context instance. + + Returns: + Nothing. + """ + obj = context.object if obj is None: return False @@ -173,7 +181,15 @@ class PDT_OT_ViewPlaneScale(Operator): @classmethod def poll(cls, context): - """Check Onject Status.""" + """Check Object Status. + + Args: + context: Blender bpy.context instance. + + Returns: + Nothing. + """ + obj = context.object if obj is None: return False @@ -285,7 +301,15 @@ class PDT_OT_PivotSelected(Operator): @classmethod def poll(cls, context): - """Check Onject Status.""" + """Check Object Status. + + Args: + context: Blender bpy.context instance. + + Returns: + Nothing. + """ + obj = context.object if obj is None: return False @@ -337,7 +361,15 @@ class PDT_OT_PivotOrigin(Operator): @classmethod def poll(cls, context): - """Check Onject Status.""" + """Check Object Status. + + Args: + context: Blender bpy.context instance. + + Returns: + Nothing. + """ + obj = context.object if obj is None: return False @@ -377,7 +409,15 @@ class PDT_OT_PivotWrite(Operator): @classmethod def poll(cls, context): - """Check Onject Status.""" + """Check Object Status. + + Args: + context: Blender bpy.context instance. + + Returns: + Nothing. + """ + obj = context.object if obj is None: return False @@ -425,7 +465,15 @@ class PDT_OT_PivotRead(Operator): @classmethod def poll(cls, context): - """Check Onject Status.""" + """Check Object Status. + + Args: + context: Blender bpy.context instance. + + Returns: + Nothing. + """ + obj = context.object if obj is None: return False diff --git a/precision_drawing_tools/pdt_view.py b/precision_drawing_tools/pdt_view.py index 087ce2f5..e7fb87cc 100644 --- a/precision_drawing_tools/pdt_view.py +++ b/precision_drawing_tools/pdt_view.py @@ -85,7 +85,8 @@ class PDT_OT_ViewRotL(Operator): Notes: Uses pg.vrotangle scene variable - Returns: Status Set. + Returns: + Status Set. """ scene = context.scene @@ -229,7 +230,8 @@ class PDT_OT_ViewIso(Operator): Returns: Status Set. """ - # Try working this out in your head! + + # Rotate view 45 degrees about Z then 32.2644 about X context.region_data.view_rotation = Quaternion((0.8205, 0.4247, -0.1759, -0.3399)) context.region_data.view_perspective = "ORTHO" return {"FINISHED"} diff --git a/precision_drawing_tools/pdt_xall.py b/precision_drawing_tools/pdt_xall.py index dd690284..f14fc292 100644 --- a/precision_drawing_tools/pdt_xall.py +++ b/precision_drawing_tools/pdt_xall.py @@ -40,6 +40,7 @@ def order_points(edge, point_list): v1, v2 = edge def dist(coord): + """MEasure distance between two coordinates.""" return (v1 - coord).length point_list = sorted(point_list, key=dist) @@ -47,7 +48,15 @@ def order_points(edge, point_list): def remove_permutations_that_share_a_vertex(bm, permutations): - """Get useful Permutations.""" + """Get useful Permutations. + + Args: + bm: Object's Bmesh + permutations: Possible Intersection Edges as a list + + Returns: + List of Edges. + """ final_permutations = [] for edges in permutations: @@ -62,7 +71,15 @@ def remove_permutations_that_share_a_vertex(bm, permutations): def get_valid_permutations(bm, edge_indices): - """Get useful Permutations.""" + """Get useful Permutations. + + Args: + bm: Object's Bmesh + edge_indices: List of indices of Edges to consider + + Returns: + List of suitable Edges. + """ raw_permutations = itertools.permutations(edge_indices, 2) permutations = [r for r in raw_permutations if r[0] < r[1]] @@ -71,7 +88,15 @@ def get_valid_permutations(bm, edge_indices): def can_skip(closest_points, vert_vectors): """Check if the intersection lies on both edges and return True - when criteria are not met, and thus this point can be skipped.""" + when criteria are not met, and thus this point can be skipped. + + Args: + closest_points: List of Coordinates of points to consider + vert_vectors: List of Coordinates of vertices to consider + + Returns: + Boolean. + """ if not closest_points: return True @@ -86,7 +111,15 @@ def can_skip(closest_points, vert_vectors): def get_intersection_dictionary(bm, edge_indices): - """Return a dictionary of edge indices and points found on those edges.""" + """Return a dictionary of edge indices and points found on those edges. + + Args: + bm, Object's Bmesh + edge_indices: List of Edge Indices + + Returns: + Dictionary of Vectors. + """ bm.verts.ensure_lookup_table() bm.edges.ensure_lookup_table() @@ -109,7 +142,7 @@ def get_intersection_dictionary(bm, edge_indices): # reaches this point only when an intersection happens on both edges. [list_k[edge].append(points[0]) for edge in edges] - # k will contain a dict of edge indices and points found on those edges. + # list_k will contain a dict of edge indices and points found on those edges. for edge_idx, unordered_points in list_k.items(): tv1, tv2 = bm.edges[edge_idx].verts v1 = bm.verts[tv1.index].co @@ -121,7 +154,15 @@ def get_intersection_dictionary(bm, edge_indices): def update_mesh(bm, int_dict): - """Make new geometry (delete old first).""" + """Make new geometry (delete old first). + + Args: + bm, Object's Bmesh + int_dict: Dictionary of Indices of Vertices + + Returns: + Nothing. + """ orig_e = bm.edges orig_v = bm.verts @@ -142,7 +183,16 @@ def update_mesh(bm, int_dict): def unselect_nonintersecting(bm, d_edges, edge_indices): - """Deselects Non-Intersection Edges""" + """Deselects Non-Intersection Edges. + + Args: + bm, Object's Bmesh + d_edges: List of Intersecting Edges + edge_indices: List of Edge Indices to consider + + Returns: + Nothing. + """ if len(edge_indices) > len(d_edges): reserved_edges = set(edge_indices) - set(d_edges) @@ -204,7 +254,6 @@ class PDT_OT_IntersectAllEdges(bpy.types.Operator): """Check to see object is in correct condidtion. Args: - Class, context: Blender bpy.context instance. Returns: |