MCPcopy
hub / github.com/CadQuery/cadquery / makeHelix

Method makeHelix

cadquery/occ_impl/shapes.py:3063–3109  ·  view source on GitHub ↗

Make a helix with a given pitch, height and radius By default a cylindrical surface is used to create the helix. If the fourth parameter is set (the apex given in degree) a conical surface is used instead'

(
        cls,
        pitch: float,
        height: float,
        radius: float,
        center: VectorLike = Vector(0, 0, 0),
        dir: VectorLike = Vector(0, 0, 1),
        angle: float = 360.0,
        lefthand: bool = False,
    )

Source from the content-addressed store, hash-verified

3061
3062 @classmethod
3063 def makeHelix(
3064 cls,
3065 pitch: float,
3066 height: float,
3067 radius: float,
3068 center: VectorLike = Vector(0, 0, 0),
3069 dir: VectorLike = Vector(0, 0, 1),
3070 angle: float = 360.0,
3071 lefthand: bool = False,
3072 ) -> Wire:
3073 """
3074 Make a helix with a given pitch, height and radius
3075 By default a cylindrical surface is used to create the helix. If
3076 the fourth parameter is set (the apex given in degree) a conical surface is used instead'
3077 """
3078
3079 # 1. build underlying cylindrical/conical surface
3080 if angle == 360.0:
3081 geom_surf: Geom_Surface = Geom_CylindricalSurface(
3082 gp_Ax3(Vector(center).toPnt(), Vector(dir).toDir()), radius
3083 )
3084 else:
3085 geom_surf = Geom_ConicalSurface(
3086 gp_Ax3(Vector(center).toPnt(), Vector(dir).toDir()),
3087 radians(angle),
3088 radius,
3089 )
3090
3091 # 2. construct an segment in the u,v domain
3092 if lefthand:
3093 geom_line = Geom2d_Line(gp_Pnt2d(0.0, 0.0), gp_Dir2d(-2 * pi, pitch))
3094 else:
3095 geom_line = Geom2d_Line(gp_Pnt2d(0.0, 0.0), gp_Dir2d(2 * pi, pitch))
3096
3097 # 3. put it together into a wire
3098 n_turns = height / pitch
3099 u_start = geom_line.Value(0.0)
3100 u_stop = geom_line.Value(n_turns * sqrt((2 * pi) ** 2 + pitch ** 2))
3101 geom_seg = GCE2d_MakeSegment(u_start, u_stop).Value()
3102
3103 e = BRepBuilderAPI_MakeEdge(geom_seg, geom_surf).Edge()
3104
3105 # 4. Convert to wire and fix building 3d geom from 2d geom
3106 w = BRepBuilderAPI_MakeWire(e).Wire()
3107 BRepLib.BuildCurves3d_s(w, 1e-6, MaxSegment=2000) # NB: preliminary values
3108
3109 return cls(w)
3110
3111 def stitch(self, other: Wire) -> Wire:
3112 """Attempt to stitch wires"""

Callers 4

testMakeHelixMethod · 0.80
testLocationAtMethod · 0.80

Calls 3

VectorClass · 0.85
toPntMethod · 0.80
toDirMethod · 0.80

Tested by 2

testMakeHelixMethod · 0.64
testLocationAtMethod · 0.64