How to sweep a profile with holes along a path? #1978
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Beta Was this translation helpful? Give feedback.
-
|
Thank you for the response! I had to dig into the functional api to understand it better, but it seems easier than the main one. I was able to use your example to get a straight line, quarter circle, a jog bend, and a full circle to work. However, I am struggling with the helix path. I suspect it may have to do with the orientation of the face and the start of the helix path, but I am struggling to visualize the orientation. Is there a better way to automatically orient my face to the path? Would significantly simplify my logic if I could orient the face to it always is perpendicular to the wire path before I sweep. Here is some code that doesn't work, seems to hang before completing. I am guessing the face is in the wrong location and orientation and is causing erroneously complex shapes for the engine to process. import cadquery as cq
from cadquery.func import *
def create_faces(outer_size = 14.5):
# Ring profile: outer ring + inner ring (half size, same thickness)
inner_size = outer_size * 0.90 # outer ring hole 90% the size of the outer
thickness = outer_size - inner_size
# Inner ring: half the size of outer, same thickness
inner_ring_outer_r = outer_size / 2
inner_ring_inner_r = inner_ring_outer_r - thickness
# Outer ring
outer_full = face(circle(outer_size))
outer = outer_full - face(circle(inner_size))
# Inner ring
inner = face(circle(inner_ring_outer_r))
# Inner hole
inner_hole = plane(inner_ring_inner_r*1.75, inner_ring_outer_r)
# Bar
rect = plane(2*outer_size, thickness) * outer_full
# combine and return
return clean(fuse(inner, outer, (rect)) - inner_hole)
print('creating profile')
outer_size = 14.5
#solid face
# faces = clean(face(circle(outer_size)))
#complex faces
faces = create_faces(outer_size)
print('creating path')
height = 100
width = 100
# straight
# path = spline([(0,0,0), (0,0,height)], tgts=[(0,0,1), (0,0,1)])
# quarter circle
# path = spline([(0,0,0),(0,width,width)], tgts=[(0,0,1), (0,1,0)])
# jog bend
# path = spline(
# [
# (0, 0, 0),
# (0, width / 2, height / 2), # Middle of jog
# (0, width, height) # Final point
# ],
# tgts=[(0, 0, 1), (0, 0, 1)] # Start and end both pointing up in Z direction
# )
# circle - create a 3D circular path in the XY plane
# path = circle(width).move(rx=90).move(z=-width)
# faces = faces.move(ry=90)
# Helix
path = cq.Wire.makeHelix(pitch=0.9, height=height, radius=width/2).move(rx=90).move(z=-width)
faces = faces.move(ry=90)
print('profile created')
print('sweeping')
result = sweep(faces,path)
# print('exporting')
# cq.exporters.export(result, "test2.stl")
# print('export done')
# from yacv_server import yacv, show
# show(result, names='test2') |
Beta Was this translation helpful? Give feedback.





Yes, you are likely using to small path and because of that getting weird results.
Working example: