/// The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect.
instances: number(Count),
/// How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples.
transform: fn(number(Count)): {},
/// If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid.
/// Which sketches to loft. Must include at least 2 sketches.
@sketches: [Sketch; 2+],
/// Degree of the interpolation. Must be greater than zero. For example, use 2 for quadratic, or 3 for cubic interpolation in the V direction.
vDegree?: number(Count) = 2,
/// Attempt to approximate rational curves (such as arcs) using a bezier. This will remove banding around interpolations between arcs and non-arcs. It may produce errors in other scenarios. Over time, this field won't be necessary.
bezApproximateRational?: bool = false,
/// This can be set to override the automatically determined topological base curve, which is usually the first section encountered.
baseCurveIndex?: number(Count),
/// Tolerance for the loft operation.
tolerance?: number(Length),
/// A named tag for the face at the start of the loft, i.e. the original sketch.
tagStart?: tag,
/// A named tag for the face at the end of the loft.
tagEnd?: tag,
): Solid {}
/// Repeat a 2-dimensional sketch along some dimension, with a dynamic amount
/// of distance between each repetition, some specified number of times.
///
/// ```kcl
/// /// Pattern using a named axis.
///
/// exampleSketch = startSketchOn(XZ)
/// |> circle(center = [0, 0], radius = 1)
/// |> patternLinear2d(
/// axis = X,
/// instances = 7,
/// distance = 4
/// )
///
/// example = extrude(exampleSketch, length = 1)
/// ```
///
/// ```kcl
/// /// Pattern using a raw axis.
///
/// exampleSketch = startSketchOn(XZ)
/// |> circle(center = [0, 0], radius = 1)
/// |> patternLinear2d(
/// axis = [1, 0],
/// instances = 7,
/// distance = 4
/// )
///
/// example = extrude(exampleSketch, length = 1)
/// ```
@(impl = std_rust)
export fn patternLinear2d(
/// The sketch(es) to duplicate.
@sketches: [Sketch; 1+],
/// The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect.
instances: number(Count),
/// Distance between each repetition. Also known as 'spacing'.
distance: number(Length),
/// The axis of the pattern. A 2D vector.
@(snippetArray = ["1", "0"])
axis: Axis2d | Point2d,
/// If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid.
useOriginal?: bool = false,
): [Sketch; 1+] {}
/// Repeat a 2-dimensional sketch some number of times along a partial or
/// complete circle some specified number of times. Each object may
/// additionally be rotated along the circle, ensuring orientation of the
/// solid with respect to the center of the circle is maintained.
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [.5, 25])
/// |> line(end = [0, 5])
/// |> line(end = [-1, 0])
/// |> line(end = [0, -5])
/// |> close()
/// |> patternCircular2d(
/// center = [0, 0],
/// instances = 13,
/// arcDegrees = 360,
/// rotateDuplicates = true
/// )
///
/// example = extrude(exampleSketch, length = 1)
/// ```
@(impl = std_rust)
export fn patternCircular2d(
/// The sketch(es) to duplicate.
@sketches: [Sketch; 1+],
/// The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect.
instances: number(Count),
/// The center about which to make the pattern. This is a 2D vector.
@(snippetArray = ["0", "0"])
center: Point2d,
/// The arc angle (in degrees) to place the repetitions. Must be greater than 0.
arcDegrees?: number(Angle) = 360deg,
/// Whether or not to rotate the duplicates as they are copied.
rotateDuplicates?: bool = true,
/// If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid.
/// The involute is described between two circles, start_radius is the radius of the inner circle.
startRadius: number(Length),
/// The involute is described between two circles, end_radius is the radius of the outer circle.
endRadius: number(Length),
/// The angle to rotate the involute by. A value of zero will produce a curve with a tangent along the x-axis at the start point of the curve.
angle: number(Angle),
/// If reverse is true, the segment will start from the end of the involute, otherwise it will start from that start.
reverse?: bool = false,
/// Create a new tag which refers to this line.
tag?: tag,
): Sketch {}
/// Extend the current sketch with a new straight line.
///
/// ```kcl
/// triangle = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// // The END argument means it ends at exactly [10, 0].
/// // This is an absolute measurement, it is NOT relative to
/// // the start of the sketch.
/// |> line(endAbsolute = [10, 0])
/// |> line(endAbsolute = [0, 10])
/// |> line(endAbsolute = [-10, 0], tag = $thirdLineOfTriangle)
/// |> close()
/// |> extrude(length = 5)
///
/// box = startSketchOn(XZ)
/// |> startProfile(at = [10, 10])
/// // The 'to' argument means move the pen this much.
/// // So, [10, 0] is a relative distance away from the current point.
/// |> line(end = [10, 0])
/// |> line(end = [0, 10])
/// |> line(end = [-10, 0], tag = $thirdLineOfBox)
/// |> close()
/// |> extrude(length = 5)
/// ```
@(impl = std_rust)
export fn line(
/// Which sketch should this path be added to?
@sketch: Sketch,
/// Which absolute point should this line go to? Incompatible with `end`.
endAbsolute?: Point2d,
/// How far away (along the X and Y axes) should this line go? Incompatible with `endAbsolute`.
@(includeInSnippet = true)
end?: Point2d,
/// Create a new tag which refers to this line.
tag?: tag,
): Sketch {}
/// Draw a line relative to the current origin to a specified distance away
/// from the current position along the 'x' axis.
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> xLine(length = 15)
/// |> angledLine(
/// angle = 80,
/// length = 15,
/// )
/// |> line(end = [8, -10])
/// |> xLine(length = 10)
/// |> angledLine(
/// angle = 120,
/// length = 30,
/// )
/// |> xLine(length = -15)
/// |> close()
///
/// example = extrude(exampleSketch, length = 10)
/// ```
@(impl = std_rust)
export fn xLine(
/// Which sketch should this path be added to?
@sketch: Sketch,
/// How far away along the X axis should this line go? Incompatible with `endAbsolute`.
@(includeInSnippet = true)
length?: number(Length),
/// Which absolute X value should this line go to? Incompatible with `length`.
endAbsolute?: number(Length),
/// Create a new tag which refers to this line.
tag?: tag,
): Sketch {}
/// Draw a line relative to the current origin to a specified distance away
/// from the current position along the 'y' axis.
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> yLine(length = 15)
/// |> angledLine(
/// angle = 30,
/// length = 15,
/// )
/// |> line(end = [8, -10])
/// |> yLine(length = -5)
/// |> close()
///
/// example = extrude(exampleSketch, length = 10)
/// ```
@(impl = std_rust)
export fn yLine(
/// Which sketch should this path be added to?
@sketch: Sketch,
/// How far away along the Y axis should this line go? Incompatible with `endAbsolute`.
@(includeInSnippet = true)
length?: number(Length),
/// Which absolute Y value should this line go to? Incompatible with `length`.
endAbsolute?: number(Length),
/// Create a new tag which refers to this line.
tag?: tag,
): Sketch {}
/// Draw a line segment relative to the current origin using the polar
/// measure of some angle and distance.
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> yLine(endAbsolute = 15)
/// |> angledLine(
/// angle = 30,
/// length = 15,
/// )
/// |> line(end = [8, -10])
/// |> yLine(endAbsolute = 0)
/// |> close()
///
/// example = extrude(exampleSketch, length = 10)
/// ```
@(impl = std_rust)
export fn angledLine(
/// Which sketch should this path be added to?
@sketch: Sketch,
/// Which angle should the line be drawn at?
angle: number(Angle),
/// Draw the line this distance along the given angle. Only one of `length`, `lengthX`, `lengthY`, `endAbsoluteX`, `endAbsoluteY` can be given.
length?: number(Length),
/// Draw the line this distance along the X axis. Only one of `length`, `lengthX`, `lengthY`, `endAbsoluteX`, `endAbsoluteY` can be given.
lengthX?: number(Length),
/// Draw the line this distance along the Y axis. Only one of `length`, `lengthX`, `lengthY`, `endAbsoluteX`, `endAbsoluteY` can be given.
lengthY?: number(Length),
/// Draw the line along the given angle until it reaches this point along the X axis. Only one of `length`, `lengthX`, `lengthY`, `endAbsoluteX`, `endAbsoluteY` can be given.
endAbsoluteX?: number(Length),
/// Draw the line along the given angle until it reaches this point along the Y axis. Only one of `length`, `lengthX`, `lengthY`, `endAbsoluteX`, `endAbsoluteY` can be given.
endAbsoluteY?: number(Length),
/// Create a new tag which refers to this line.
tag?: tag,
): Sketch {}
/// Draw an angled line from the current origin, constructing a line segment
/// such that the newly created line intersects the desired target line
/// segment.
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(endAbsolute = [5, 10])
/// |> line(endAbsolute = [-10, 10], tag = $lineToIntersect)
/// |> line(endAbsolute = [0, 20])
/// |> angledLineThatIntersects(
/// angle = 80,
/// intersectTag = lineToIntersect,
/// offset = 10,
/// )
/// |> close()
///
/// example = extrude(exampleSketch, length = 10)
/// ```
@(impl = std_rust)
export fn angledLineThatIntersects(
/// Which sketch should this path be added to?
@sketch: Sketch,
/// Which angle should the line be drawn at?
angle: number(Angle),
/// The tag of the line to intersect with.
intersectTag: tag,
/// The offset from the intersecting line.
offset?: number(Length) = 0mm,
/// Create a new tag which refers to this line.
tag?: tag,
): Sketch {}
/// Construct a line segment from the current origin back to the profile's
/// origin, ensuring the resulting 2-dimensional sketch is not open-ended.
///
/// If you want to perform some 3-dimensional operation on a sketch, like
/// extrude or sweep, you must `close` it first. `close` must be called even
/// if the end point of the last segment is coincident with the sketch
/// starting point.
///
/// ```kcl
/// startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [10, 10])
/// |> line(end = [10, 0])
/// |> close()
/// |> extrude(length = 10)
/// ```
///
/// ```kcl
/// exampleSketch = startSketchOn(-XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [10, 0])
/// |> line(end = [0, 10])
/// |> close()
///
/// example = extrude(exampleSketch, length = 10)
/// ```
@(impl = std_rust)
export fn close(
/// The sketch you want to close.
@sketch: Sketch,
/// Create a new tag which refers to this line.
tag?: tag,
): Sketch {}
/// Draw a curved line segment along an imaginary circle.
///
/// The arc is constructed such that the current position of the sketch is
/// placed along an imaginary circle of the specified radius, at angleStart
/// degrees. The resulting arc is the segment of the imaginary circle from
/// that origin point to angleEnd, radius away from the center of the imaginary
/// circle.
///
/// Unless this makes a lot of sense and feels like what you're looking
/// for to construct your shape, you're likely looking for tangentialArc.
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [10, 0])
/// |> arc(
/// angleStart = 0,
/// angleEnd = 280,
/// radius = 16
/// )
/// |> close()
/// example = extrude(exampleSketch, length = 10)
/// ```
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> arc(
/// endAbsolute = [10,0],
/// interiorAbsolute = [5,5]
/// )
/// |> close()
/// example = extrude(exampleSketch, length = 10)
/// ```
@(impl = std_rust)
export fn arc(
/// Which sketch should this path be added to?
@sketch: Sketch,
/// Where along the circle should this arc start?
@(includeInSnippet = true)
angleStart?: number(Angle),
/// Where along the circle should this arc end?
@(includeInSnippet = true)
angleEnd?: number(Angle),
/// How large should the circle be? Incompatible with `diameter`.
radius?: number(Length),
/// How large should the circle be? Incompatible with `radius`.
@(includeInSnippet = true)
diameter?: number(Length),
/// Any point between the arc's start and end? Requires `endAbsolute`. Incompatible with `angleStart` or `angleEnd`.
interiorAbsolute?: Point2d,
/// Where should this arc end? Requires `interiorAbsolute`. Incompatible with `angleStart` or `angleEnd`.
endAbsolute?: Point2d,
/// Create a new tag which refers to this arc.
tag?: tag,
): Sketch {}
/// Starting at the current sketch's origin, draw a curved line segment along
/// some part of an imaginary circle until it reaches the desired (x, y)
/// coordinates.
///
/// When using radius and angle, draw a curved line segment along part of an
/// imaginary circle. The arc is constructed such that the last line segment is
/// placed tangent to the imaginary circle of the specified radius. The
/// resulting arc is the segment of the imaginary circle from that tangent point
/// for 'angle' degrees along the imaginary circle.
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 45,
/// length = 10,
/// )
/// |> tangentialArc(end = [0, -10])
/// |> line(end = [-10, 0])
/// |> close()
///
/// example = extrude(exampleSketch, length = 10)
/// ```
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 60,
/// length = 10,
/// )
/// |> tangentialArc(endAbsolute = [15, 15])
/// |> line(end = [10, -15])
/// |> close()
///
/// example = extrude(exampleSketch, length = 10)
/// ```
///
/// ```kcl
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> angledLine(
/// angle = 60,
/// length = 10,
/// )
/// |> tangentialArc(radius = 10, angle = -120)
/// |> angledLine(
/// angle = -60,
/// length = 10,
/// )
/// |> close()
///
/// example = extrude(exampleSketch, length = 10)
/// ```
@(impl = std_rust)
export fn tangentialArc(
/// Which sketch should this path be added to?
@sketch: Sketch,
/// Which absolute point should this arc go to? Incompatible with `end`, `radius`, and `offset`.
endAbsolute?: Point2d,
/// How far away (along the X and Y axes) should this arc go? Incompatible with `endAbsolute`, `radius`, and `offset`.
@(includeInSnippet = true)
end?: Point2d,
/// Radius of the imaginary circle. `angle` must be given. Incompatible with `end` and `endAbsolute` and `diameter`.
radius?: number(Length),
/// Diameter of the imaginary circle. `angle` must be given. Incompatible with `end` and `endAbsolute` and `radius`.
diameter?: number(Length),
/// Offset of the arc. `radius` must be given. Incompatible with `end` and `endAbsolute`.
angle?: number(Angle),
/// Create a new tag which refers to this arc.
tag?: tag,
): Sketch {}
/// Draw a smooth, continuous, curved line segment from the current origin to
/// the desired (x, y), using a number of control points to shape the curve's