Draft: fix division by zero and count is zero for path arrays
Fixes #16468.
This commit is contained in:
@@ -64,8 +64,9 @@ def get_init_values(path, count=6):
|
||||
edge = path.Shape.Edges[0]
|
||||
edge_length = edge.Length
|
||||
|
||||
step = edge_length / (count - 1)
|
||||
inc = 360 / (count - 1)
|
||||
n = (count - 1) if count > 1 else 1
|
||||
step = edge_length / n
|
||||
inc = 360 / n
|
||||
|
||||
return norm, edge, step, inc
|
||||
|
||||
@@ -84,6 +85,9 @@ def get_n_params(edge, number, step, norm):
|
||||
|
||||
def get_twisted_placements(path, count=15, rot_factor=0.25):
|
||||
"""Get the placements of the twisted array elements."""
|
||||
if count < 1:
|
||||
count = 1
|
||||
|
||||
(norm, edge,
|
||||
step, inc) = get_init_values(path, count)
|
||||
|
||||
|
||||
@@ -475,14 +475,19 @@ def placements_on_path(shapeRotation, pathwire, count, xlate, align,
|
||||
end = endOffset
|
||||
|
||||
cdist = cdist - start - end
|
||||
step = cdist / (count if (DraftGeomUtils.isReallyClosed(pathwire) and not (start or end)) else count - 1)
|
||||
if count < 1:
|
||||
count = 1
|
||||
n = count if (DraftGeomUtils.isReallyClosed(pathwire) and not (start or end)) else count - 1
|
||||
if n == 0:
|
||||
n = 1
|
||||
step = cdist / n
|
||||
remains = 0
|
||||
travel = start
|
||||
placements = []
|
||||
|
||||
for i in range(0, count):
|
||||
for i in range(count):
|
||||
# which edge in path should contain this shape?
|
||||
for j in range(0, len(ends)):
|
||||
for j in range(len(ends)):
|
||||
if travel <= ends[j]:
|
||||
iend = j
|
||||
remains = ends[iend] - travel
|
||||
|
||||
Reference in New Issue
Block a user