Draft: various cleanup

Mainly added an empty line at the end of each file and changed docstrings.
This commit is contained in:
carlopav
2020-05-12 20:59:17 +02:00
committed by Yorik van Havre
parent 2c4de88132
commit 125d0ca84d
57 changed files with 170 additions and 113 deletions

View File

@@ -60,49 +60,53 @@ def array(objectslist, arg1, arg2, arg3, arg4=None, arg5=None, arg6=None):
array(objectslist, center, totalangle, totalnum) for polar array
"""
def rectArray(objectslist,xvector,yvector,xnum,ynum):
utils.type_check([(xvector, App.Vector),
(yvector, App.Vector),
(xnum,int), (ynum,int)],
"rectArray")
if not isinstance(objectslist,list): objectslist = [objectslist]
for xcount in range(xnum):
currentxvector=App.Vector(xvector).multiply(xcount)
if not xcount==0:
move(objectslist,currentxvector,True)
for ycount in range(ynum):
currentxvector=App.Vector(currentxvector)
currentyvector=currentxvector.add(App.Vector(yvector).multiply(ycount))
if not ycount==0:
move(objectslist,currentyvector,True)
def rectArray2(objectslist,xvector,yvector,zvector,xnum,ynum,znum):
utils.type_check([(xvector,App.Vector), (yvector,App.Vector), (zvector,App.Vector),(xnum,int), (ynum,int),(znum,int)], "rectArray2")
if not isinstance(objectslist,list): objectslist = [objectslist]
for xcount in range(xnum):
currentxvector=App.Vector(xvector).multiply(xcount)
if not xcount==0:
move(objectslist,currentxvector,True)
for ycount in range(ynum):
currentxvector=App.Vector(currentxvector)
currentyvector=currentxvector.add(App.Vector(yvector).multiply(ycount))
if not ycount==0:
move(objectslist,currentyvector,True)
for zcount in range(znum):
currentzvector=currentyvector.add(App.Vector(zvector).multiply(zcount))
if not zcount==0:
move(objectslist,currentzvector,True)
def polarArray(objectslist,center,angle,num):
utils.type_check([(center,App.Vector), (num,int)], "polarArray")
if not isinstance(objectslist,list): objectslist = [objectslist]
fraction = float(angle)/num
for i in range(num):
currangle = fraction + (i*fraction)
rotate(objectslist,currangle,center,copy=True)
if arg6:
rectArray2(objectslist,arg1,arg2,arg3,arg4,arg5,arg6)
rectArray2(objectslist, arg1, arg2, arg3, arg4, arg5, arg6)
elif arg4:
rectArray(objectslist,arg1,arg2,arg3,arg4)
rectArray(objectslist, arg1,arg2, arg3, arg4)
else:
polarArray(objectslist,arg1,arg2,arg3)
polarArray(objectslist, arg1, arg2, arg3)
def rectArray(objectslist,xvector,yvector,xnum,ynum):
utils.type_check([(xvector, App.Vector),
(yvector, App.Vector),
(xnum,int), (ynum,int)],
"rectArray")
if not isinstance(objectslist,list): objectslist = [objectslist]
for xcount in range(xnum):
currentxvector=App.Vector(xvector).multiply(xcount)
if not xcount==0:
move(objectslist,currentxvector,True)
for ycount in range(ynum):
currentxvector=App.Vector(currentxvector)
currentyvector=currentxvector.add(App.Vector(yvector).multiply(ycount))
if not ycount==0:
move(objectslist,currentyvector,True)
def rectArray2(objectslist,xvector,yvector,zvector,xnum,ynum,znum):
utils.type_check([(xvector,App.Vector), (yvector,App.Vector), (zvector,App.Vector),(xnum,int), (ynum,int),(znum,int)], "rectArray2")
if not isinstance(objectslist,list): objectslist = [objectslist]
for xcount in range(xnum):
currentxvector=App.Vector(xvector).multiply(xcount)
if not xcount==0:
move(objectslist,currentxvector,True)
for ycount in range(ynum):
currentxvector=App.Vector(currentxvector)
currentyvector=currentxvector.add(App.Vector(yvector).multiply(ycount))
if not ycount==0:
move(objectslist,currentyvector,True)
for zcount in range(znum):
currentzvector=currentyvector.add(App.Vector(zvector).multiply(zcount))
if not zcount==0:
move(objectslist,currentzvector,True)
def polarArray(objectslist,center,angle,num):
utils.type_check([(center,App.Vector), (num,int)], "polarArray")
if not isinstance(objectslist,list): objectslist = [objectslist]
fraction = float(angle)/num
for i in range(num):
currangle = fraction + (i*fraction)
rotate(objectslist,currangle,center,copy=True)

View File

@@ -271,4 +271,3 @@ def downgrade(objects, delete=False, force=None):
App.ActiveDocument.removeObject(n)
gui_utils.select(addList)
return [addList,deleteList]

View File

@@ -112,4 +112,4 @@ def heal(objlist=None, delete=True, reparent=True):
if dellist and delete:
for n in dellist:
App.ActiveDocument.removeObject(n)
App.ActiveDocument.removeObject(n)

View File

@@ -88,4 +88,4 @@ def join_two_wires(wire1, wire2):
return True
joinTwoWires = join_two_wires
joinTwoWires = join_two_wires

View File

@@ -169,6 +169,10 @@ def move(objectslist, vector, copy=False):
def move_vertex(object, vertex_index, vector):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
points = object.Points
points[vertex_index] = points[vertex_index].add(vector)
object.Points = points
@@ -178,6 +182,10 @@ moveVertex = move_vertex
def move_edge(object, edge_index, vector):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
moveVertex(object, edge_index, vector)
if utils.isClosedEdge(edge_index, object):
moveVertex(object, 0, vector)
@@ -189,6 +197,10 @@ moveEdge = move_edge
def copy_moved_edges(arguments):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
copied_edges = []
for argument in arguments:
copied_edges.append(copy_moved_edge(argument[0], argument[1], argument[2]))
@@ -199,6 +211,10 @@ copyMovedEdges = copy_moved_edges
def copy_moved_edge(object, edge_index, vector):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
vertex1 = object.Placement.multVec(object.Points[edge_index]).add(vector)
if utils.isClosedEdge(edge_index, object):
vertex2 = object.Placement.multVec(object.Points[0]).add(vector)

View File

@@ -154,6 +154,10 @@ def rotate(objectslist, angle, center=App.Vector(0,0,0),
def rotate_vertex(object, vertex_index, angle, center, axis):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
points = object.Points
points[vertex_index] = object.Placement.inverse().multVec(
rotate_vector_from_center(
@@ -166,6 +170,10 @@ rotateVertex = rotate_vertex
def rotate_vector_from_center(vector, angle, axis, center):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
rv = vector.sub(center)
rv = DraftVecUtils.rotate(rv, math.radians(angle), axis)
return center.add(rv)
@@ -175,6 +183,10 @@ rotateVectorFromCenter = rotate_vector_from_center
def rotate_edge(object, edge_index, angle, center, axis):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
rotateVertex(object, edge_index, angle, center, axis)
if utils.isClosedEdge(edge_index, object):
rotateVertex(object, 0, angle, center, axis)
@@ -186,6 +198,10 @@ rotateEdge = rotate_edge
def copy_rotated_edges(arguments):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
copied_edges = []
for argument in arguments:
copied_edges.append(copy_rotated_edge(argument[0], argument[1],
@@ -197,6 +213,10 @@ copyRotatedEdges = copy_rotated_edges
def copy_rotated_edge(object, edge_index, angle, center, axis):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
vertex1 = rotate_vector_from_center(
object.Placement.multVec(object.Points[edge_index]),
angle, axis, center)
@@ -208,4 +228,5 @@ def copy_rotated_edge(object, edge_index, angle, center, axis):
vertex2 = rotate_vector_from_center(
object.Placement.multVec(object.Points[edge_index+1]),
angle, axis, center)
return make_line(vertex1, vertex2)
return make_line(vertex1, vertex2)

View File

@@ -129,6 +129,10 @@ def scale(objectslist, scale=App.Vector(1,1,1),
def scale_vertex(obj, vertex_index, scale, center):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
points = obj.Points
points[vertex_index] = obj.Placement.inverse().multVec(
scaleVectorFromCenter(
@@ -141,6 +145,10 @@ scaleVertex = scale_vertex
def scale_vector_from_center(vector, scale, center):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
return vector.sub(center).scale(scale.x, scale.y, scale.z).add(center)
@@ -148,6 +156,10 @@ scaleVectorFromCenter = scale_vector_from_center
def scale_edge(obj, edge_index, scale, center):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
scaleVertex(obj, edge_index, scale, center)
if utils.isClosedEdge(edge_index, obj):
scaleVertex(obj, 0, scale, center)
@@ -159,6 +171,10 @@ scaleEdge = scale_edge
def copy_scaled_edge(obj, edge_index, scale, center):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
import Part
vertex1 = scaleVectorFromCenter(
obj.Placement.multVec(obj.Points[edge_index]),
@@ -178,6 +194,10 @@ copyScaledEdge = copy_scaled_edge
def copy_scaled_edges(arguments):
"""
Needed for SubObjects modifiers.
Implemented by Dion Moult during 0.19 dev cycle (works only with Draft Wire).
"""
copied_edges = []
for argument in arguments:
copied_edges.append(copyScaledEdge(argument[0], argument[1],
@@ -185,4 +205,4 @@ def copy_scaled_edges(arguments):
join_wires(copied_edges)
copyScaledEdges = copy_scaled_edges
copyScaledEdges = copy_scaled_edges

View File

@@ -70,4 +70,4 @@ def split_open_wire(wire, newPoint, edgeIndex):
make_wire(wire2Points, placement=wire.Placement)
splitOpenWire = split_open_wire
splitOpenWire = split_open_wire