Skip to content

Commit

Permalink
Permit 0-length initial perforation (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erhannis authored Sep 21, 2024
1 parent 2d68ea7 commit 2039870
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions SheetMetalCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,23 +211,30 @@ def smMakePerforationFace(
pivotL = extLen - pivotL
swingL = extLen - swingL

totalFace = None

# Initial perf, near
p1 = edge.valueAt(edge.FirstParameter + gap1) + dir.normalize() * pivotL
p2 = edge.valueAt(edge.FirstParameter + gap1 + lenIPerf1) + dir.normalize() * pivotL
p3 = edge.valueAt(edge.FirstParameter + gap1 + lenIPerf1) + dir.normalize() * swingL
p4 = edge.valueAt(edge.FirstParameter + gap1) + dir.normalize() * swingL
w = Part.makePolygon([p1, p2, p3, p4, p1])
face = Part.Face(w)
totalFace = face
if lenIPerf1 > 0:
p1 = edge.valueAt(edge.FirstParameter + gap1) + dir.normalize() * pivotL
p2 = edge.valueAt(edge.FirstParameter + gap1 + lenIPerf1) + dir.normalize() * pivotL
p3 = edge.valueAt(edge.FirstParameter + gap1 + lenIPerf1) + dir.normalize() * swingL
p4 = edge.valueAt(edge.FirstParameter + gap1) + dir.normalize() * swingL
w = Part.makePolygon([p1, p2, p3, p4, p1])
face = Part.Face(w)
totalFace = face

# Initial perf, far
p1 = edge.valueAt(edge.LastParameter - gap2 - lenIPerf2) + dir.normalize() * pivotL
p2 = edge.valueAt(edge.LastParameter - gap2) + dir.normalize() * pivotL
p3 = edge.valueAt(edge.LastParameter - gap2) + dir.normalize() * swingL
p4 = edge.valueAt(edge.LastParameter - gap2 - lenIPerf2) + dir.normalize() * swingL
w = Part.makePolygon([p1, p2, p3, p4, p1])
face = Part.Face(w)
totalFace = totalFace.fuse(face)
if lenIPerf2 > 0:
p1 = edge.valueAt(edge.LastParameter - gap2 - lenIPerf2) + dir.normalize() * pivotL
p2 = edge.valueAt(edge.LastParameter - gap2) + dir.normalize() * pivotL
p3 = edge.valueAt(edge.LastParameter - gap2) + dir.normalize() * swingL
p4 = edge.valueAt(edge.LastParameter - gap2 - lenIPerf2) + dir.normalize() * swingL
w = Part.makePolygon([p1, p2, p3, p4, p1])
face = Part.Face(w)
if totalFace == None:
totalFace = face
else:
totalFace = totalFace.fuse(face)

# Perforations, inner
for i in range(P):
Expand All @@ -238,7 +245,10 @@ def smMakePerforationFace(
p4 = edge.valueAt(x) + dir.normalize() * swingL
w = Part.makePolygon([p1, p2, p3, p4, p1])
face = Part.Face(w)
totalFace = totalFace.fuse(face)
if totalFace == None:
totalFace = face
else:
totalFace = totalFace.fuse(face)

if hasattr(totalFace, "mapShapes"):
totalFace.mapShapes([(edge, totalFace)], None, op)
Expand Down

0 comments on commit 2039870

Please sign in to comment.