[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1604] contrib/py/scripts/addons/ mesh_edge_intersection_tools.py: more pep8 compliant
Dealga McArdle
tetha.z at gmail.com
Tue Feb 15 11:00:39 CET 2011
Revision: 1604
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1604
Author: zeffii
Date: 2011-02-15 10:00:39 +0000 (Tue, 15 Feb 2011)
Log Message:
-----------
more pep8 compliant
Modified Paths:
--------------
contrib/py/scripts/addons/mesh_edge_intersection_tools.py
Modified: contrib/py/scripts/addons/mesh_edge_intersection_tools.py
===================================================================
--- contrib/py/scripts/addons/mesh_edge_intersection_tools.py 2011-02-15 09:45:24 UTC (rev 1603)
+++ contrib/py/scripts/addons/mesh_edge_intersection_tools.py 2011-02-15 10:00:39 UTC (rev 1604)
@@ -21,7 +21,7 @@
bl_info = {
"name": "Edge tools : tinyCAD VTX",
"author": "zeffii",
- "version": (0,5,1),
+ "version": (0, 5, 1),
"blender": (2, 5, 6),
"api": 34840,
"category": "Mesh",
@@ -37,8 +37,8 @@
parts based on Keith (Wahooney) Boshoff, cursor to intersection script and
Paul Bourke's Shortest Line Between 2 lines, and thanks to PKHG from BA.org
for attempting to explain things to me that i'm not familiar with.
-TODO: [ ] allow multi selection ( > 2 ) for Slice/Weld intersection mode
-TODO: [ ] streamline this code !
+TODO: [ ] allow multi selection ( > 2 ) for Slice/Weld intersection mode
+TODO: [ ] streamline this code !
1) Edge Extend To Edge ( T )
2) Edge Slice Intersecting ( X )
@@ -139,26 +139,26 @@
oe.add(4)
# Candidate for serious optimization.
if isPointOnEdge(vX, vA, vB):
- oe[edge_count].vertices = [vert_count,vert_count+1]
- oe[edge_count+1].vertices = [vert_count,vert_count+2]
+ oe[edge_count].vertices = [vert_count, vert_count+1]
+ oe[edge_count+1].vertices = [vert_count, vert_count+2]
# find which of C and D is farthest away from X
if mDist(vD, vX) > mDist(vC, vX):
- oe[edge_count+2].vertices = [vert_count,vert_count+3]
- oe[edge_count+3].vertices = [vert_count+3,vert_count+4]
+ oe[edge_count+2].vertices = [vert_count, vert_count+3]
+ oe[edge_count+3].vertices = [vert_count+3, vert_count+4]
if mDist(vC, vX) > mDist(vD, vX):
- oe[edge_count+2].vertices = [vert_count,vert_count+4]
- oe[edge_count+3].vertices = [vert_count+3,vert_count+4]
+ oe[edge_count+2].vertices = [vert_count, vert_count+4]
+ oe[edge_count+3].vertices = [vert_count+3, vert_count+4]
if isPointOnEdge(vX, vC, vD):
- oe[edge_count].vertices = [vert_count,vert_count+3]
- oe[edge_count+1].vertices = [vert_count,vert_count+4]
+ oe[edge_count].vertices = [vert_count, vert_count+3]
+ oe[edge_count+1].vertices = [vert_count, vert_count+4]
# find which of A and B is farthest away from X
if mDist(vB, vX) > mDist(vA, vX):
- oe[edge_count+2].vertices = [vert_count,vert_count+1]
- oe[edge_count+3].vertices = [vert_count+1,vert_count+2]
+ oe[edge_count+2].vertices = [vert_count, vert_count+1]
+ oe[edge_count+3].vertices = [vert_count+1, vert_count+2]
if mDist(vA, vX) > mDist(vB, vX):
- oe[edge_count+2].vertices = [vert_count,vert_count+2]
- oe[edge_count+3].vertices = [vert_count+1,vert_count+2]
+ oe[edge_count+2].vertices = [vert_count, vert_count+2]
+ oe[edge_count+3].vertices = [vert_count+1, vert_count+2]
# ProjectGeometry is used to extend two edges to their intersection point.
@@ -172,16 +172,16 @@
else: return B, A
(o, vert_count, edge_count) = GetActiveObject()
- vA, vB = return_distance_checked(vX, Vector((opoint[0][0])),Vector((opoint[0][1])))
- vC, vD = return_distance_checked(vX, Vector((opoint[1][0])),Vector((opoint[1][1])))
+ vA, vB = return_distance_checked(vX, Vector((opoint[0][0])), Vector((opoint[0][1])))
+ vC, vD = return_distance_checked(vX, Vector((opoint[1][0])), Vector((opoint[1][1])))
AddVertsToObject(vert_count, o, vX, vA, vB, vC, vD)
oe = o.data.edges
oe.add(4)
oe[edge_count].vertices = [vert_count, vert_count+1]
oe[edge_count+1].vertices = [vert_count, vert_count+3]
- oe[edge_count+2].vertices = [vert_count+1,vert_count+2]
- oe[edge_count+3].vertices = [vert_count+3,vert_count+4]
+ oe[edge_count+2].vertices = [vert_count+1, vert_count+2]
+ oe[edge_count+3].vertices = [vert_count+3, vert_count+4]
def getMeshMatrix(obj):
@@ -198,7 +198,7 @@
edgenum = 0
for edge_to_test in edges:
- p1 = verts[edge_to_test.vertices[0]].co
+ p1 = verts[edge_to_test.vertices[0]].co
p2 = verts[edge_to_test.vertices[1]].co
meshMatrix.append([Vector(p1),Vector(p2)])
edgenum += 1
@@ -218,35 +218,35 @@
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.remove_doubles(limit=VTX_PRECISION)
- bpy.ops.mesh.select_all(action='TOGGLE') #unselect all
+ bpy.ops.mesh.select_all(action='TOGGLE') #unselect all
def initScriptV(context, self):
obj = bpy.context.active_object
meshMatrix = getMeshMatrix(obj)
(vert_count, edge_count) = getVertEdgeCount()
-
+
#need 2 edges to be of any use.
if len(meshMatrix) < 2:
print(str(len(meshMatrix)) +" select, make sure (only) 2 are selected")
return
-
+
#dont go any further if the verts are not coplanar
if checkIsMatrixCoplanar(meshMatrix): print("seems within tolerance, proceed")
else:
print("check your geometry, or decrease tolerance value")
return
- #if we reach this point, the edges are coplanar
- ## force edit mode
+ # if we reach this point, the edges are coplanar
+ # force edit mode
bpy.ops.object.mode_set(mode='EDIT')
vSel = bpy.context.active_object.data.total_vert_sel
if checkEdges(meshMatrix, obj) == None: print("lines dont intersect")
else:
- count = CountPointOnEdges(checkEdges(meshMatrix, obj),meshMatrix)
+ count = CountPointOnEdges(checkEdges(meshMatrix, obj), meshMatrix)
if count == 0:
- ProjectGeometry(checkEdges(meshMatrix, obj),meshMatrix)
+ ProjectGeometry(checkEdges(meshMatrix, obj), meshMatrix)
runCleanUp()
else:
print("The intersection seems to lie on 1 or 2 edges already")
@@ -262,10 +262,10 @@
if len(meshMatrix) != 2:
print(str(len(meshMatrix)) +" select 2 edges")
else:
- count = CountPointOnEdges(checkEdges(meshMatrix, obj),meshMatrix)
+ count = CountPointOnEdges(checkEdges(meshMatrix, obj), meshMatrix)
if count == 1:
print("Good, Intersection point lies on one of the two edges!")
- ExtendEdge(checkEdges(meshMatrix, obj),meshMatrix, count)
+ ExtendEdge(checkEdges(meshMatrix, obj), meshMatrix, count)
runCleanUp() #neutral function, for removing potential doubles
else:
print("Intersection point not on chosen edges")
@@ -283,18 +283,18 @@
if checkEdges(meshMatrix, obj) == None:
print("lines dont intersect")
else:
- count = CountPointOnEdges(checkEdges(meshMatrix, obj),meshMatrix)
+ count = CountPointOnEdges(checkEdges(meshMatrix, obj), meshMatrix)
if count == 2:
- makeGeometryWeld(checkEdges(meshMatrix, obj),meshMatrix)
+ makeGeometryWeld(checkEdges(meshMatrix, obj), meshMatrix)
runCleanUp()
-
+
class EdgeIntersections(bpy.types.Operator):
'''Makes a weld/slice/extend to intersecting edges/lines'''
bl_idname = 'mesh.intersections'
bl_label = 'Edge tools : tinyCAD VTX'
# bl_options = {'REGISTER', 'UNDO'}
-
+
mode = bpy.props.IntProperty(name = "Mode",
description = "switch between intersection modes",
default = 2)
@@ -323,11 +323,11 @@
def register():
bpy.utils.register_class(EdgeIntersections)
- bpy.types.VIEW3D_MT_edit_mesh_specials.append(menu_func)
+ bpy.types.VIEW3D_MT_edit_mesh_specials.append(menu_func)
def unregister():
bpy.utils.unregister_class(EdgeIntersections)
- bpy.types.VIEW3D_MT_edit_mesh_specials.remove(menu_func)
+ bpy.types.VIEW3D_MT_edit_mesh_specials.remove(menu_func)
if __name__ == "__main__":
register()
\ No newline at end of file
More information about the Bf-extensions-cvs
mailing list