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:
Diffstat (limited to 'precision_drawing_tools/pdt_xall.py')
-rw-r--r--precision_drawing_tools/pdt_xall.py48
1 files changed, 31 insertions, 17 deletions
diff --git a/precision_drawing_tools/pdt_xall.py b/precision_drawing_tools/pdt_xall.py
index 1c283cb6..dd690284 100644
--- a/precision_drawing_tools/pdt_xall.py
+++ b/precision_drawing_tools/pdt_xall.py
@@ -29,14 +29,18 @@ from mathutils.geometry import intersect_line_line as LineIntersect
import itertools
from collections import defaultdict
from . import pdt_cad_module as cm
+from .pdt_functions import oops
+from .pdt_msg_strings import (
+ PDT_ERR_EDOB_MODE
+)
def order_points(edge, point_list):
"""Order these edges from distance to v1, then sandwich the sorted list with v1, v2."""
v1, v2 = edge
- def dist(co):
- return (v1 - co).length
+ def dist(coord):
+ return (v1 - coord).length
point_list = sorted(point_list, key=dist)
return [v1] + point_list + [v2]
@@ -89,8 +93,8 @@ def get_intersection_dictionary(bm, edge_indices):
permutations = get_valid_permutations(bm, edge_indices)
- k = defaultdict(list)
- d = defaultdict(list)
+ list_k = defaultdict(list)
+ list_d = defaultdict(list)
for edges in permutations:
raw_vert_indices = cm.vertex_indices_from_edges_tuple(bm, edges)
@@ -103,35 +107,35 @@ def get_intersection_dictionary(bm, edge_indices):
continue
# reaches this point only when an intersection happens on both edges.
- [k[edge].append(points[0]) for edge in 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.
- for edge_idx, unordered_points in k.items():
+ for edge_idx, unordered_points in list_k.items():
tv1, tv2 = bm.edges[edge_idx].verts
v1 = bm.verts[tv1.index].co
v2 = bm.verts[tv2.index].co
ordered_points = order_points((v1, v2), unordered_points)
- d[edge_idx].extend(ordered_points)
+ list_d[edge_idx].extend(ordered_points)
- return d
+ return list_d
def update_mesh(bm, int_dict):
"""Make new geometry (delete old first)."""
- oe = bm.edges
- ov = bm.verts
+ orig_e = bm.edges
+ orig_v = bm.verts
new_verts = []
collect = new_verts.extend
for _, point_list in int_dict.items():
num_edges_to_add = len(point_list) - 1
for i in range(num_edges_to_add):
- a = ov.new(point_list[i])
- b = ov.new(point_list[i + 1])
- oe.new((a, b))
+ coord_a = orig_v.new(point_list[i])
+ coord_b = orig_v.new(point_list[i + 1])
+ orig_e.new((coord_a, coord_b))
bm.normal_update()
- collect([a, b])
+ collect([coord_a, coord_b])
bmesh.ops.delete(bm, geom=[edge for edge in bm.edges if edge.select], context="EDGES")
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)
@@ -178,6 +182,7 @@ def intersect_all(context):
bmesh.update_edit_mesh(obj.data)
else:
+ pg.error = f"{PDT_ERR_EDOB_MODE},{obj.mode})"
context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
return
@@ -196,10 +201,19 @@ class PDT_OT_IntersectAllEdges(bpy.types.Operator):
@classmethod
def poll(cls, context):
- ob = context.active_object
- if ob is None:
+ """Check to see object is in correct condidtion.
+
+ Args:
+ Class,
+ context: Blender bpy.context instance.
+
+ Returns:
+ Boolean
+ """
+ obj = context.active_object
+ if obj is None:
return False
- return ob is not None and ob.type == "MESH" and ob.mode == "EDIT"
+ return obj is not None and obj.type == "MESH" and obj.mode == "EDIT"
def execute(self, context):
"""Computes All intersections with Crossing Geometry.