kcl →
clone
Clone a sketch or solid.
This works essentially like a copy-paste operation.
This doesn't really have much utility unless you need the equivalent of a double instance pattern with zero transformations.
Really only use this function if YOU ARE SURE you need it. In most cases you do not need clone and using a pattern with instance = 2
is more appropriate.
clone(geometry: GeometryWithImportedGeometry): GeometryWithImportedGeometry
Arguments
Name | Type | Description | Required |
---|---|---|---|
geometry | GeometryWithImportedGeometry | The sketch, solid, or imported geometry to be cloned | Yes |
Returns
GeometryWithImportedGeometry
- A geometry including an imported geometry.
Examples
// Clone a basic sketch and move it and extrude it.
exampleSketch = startSketchOn(XY)
|> startProfileAt([0, 0], %)
|> line(end = [10, 0])
|> line(end = [0, 10])
|> line(end = [-10, 0])
|> close()
clonedSketch = clone(exampleSketch)
|> scale(x = 1.0, y = 1.0, z = 2.5)
|> translate(x = 15.0, y = 0, z = 0)
|> extrude(length = 5)
// Clone a basic solid and move it.
exampleSketch = startSketchOn(XY)
|> startProfileAt([0, 0], %)
|> line(end = [10, 0])
|> line(end = [0, 10])
|> line(end = [-10, 0])
|> close()
myPart = extrude(exampleSketch, length = 5)
clonedPart = clone(myPart)
|> translate(x = 25.0)
// Translate and rotate a cloned sketch to create a loft.
sketch001 = startSketchOn(XY)
|> startProfileAt([-10, 10], %)
|> xLine(length = 20)
|> yLine(length = -20)
|> xLine(length = -20)
|> close()
sketch002 = clone(sketch001)
|> translate(x = 0, y = 0, z = 20)
|> rotate(axis = [0, 0, 1.0], angle = 45)
loft([sketch001, sketch002])
// Translate a cloned solid. Fillet only the clone.
sketch001 = startSketchOn(XY)
|> startProfileAt([-10, 10], %)
|> xLine(length = 20)
|> yLine(length = -20)
|> xLine(length = -20, tag = $filletTag)
|> close()
|> extrude(length = 5)
sketch002 = clone(sketch001)
|> translate(x = 0, y = 0, z = 20)
|> fillet(radius = 2, tags = [getNextAdjacentEdge(filletTag)])
// You can reuse the tags from the original geometry with the cloned geometry.
sketch001 = startSketchOn(XY)
|> startProfileAt([0, 0], %)
|> line(end = [10, 0])
|> line(end = [0, 10], tag = $sketchingFace)
|> line(end = [-10, 0])
|> close()
sketch002 = clone(sketch001)
|> translate(x = 10, y = 20, z = 0)
|> extrude(length = 5)
startSketchOn(sketch002, face = sketchingFace)
|> startProfileAt([1, 1], %)
|> line(end = [8, 0])
|> line(end = [0, 8])
|> line(end = [-8, 0])
|> close(tag = $sketchingFace002)
|> extrude(length = 10)
// You can also use the tags from the original geometry to fillet the cloned geometry.
width = 20
length = 10
thickness = 1
filletRadius = 2
mountingPlateSketch = startSketchOn(XY)
|> startProfileAt([-width / 2, -length / 2], %)
|> line(endAbsolute = [width / 2, -length / 2], tag = $edge1)
|> line(endAbsolute = [width / 2, length / 2], tag = $edge2)
|> line(endAbsolute = [-width / 2, length / 2], tag = $edge3)
|> close(tag = $edge4)
mountingPlate = extrude(mountingPlateSketch, length = thickness)
clonedMountingPlate = clone(mountingPlate)
|> fillet(
radius = filletRadius,
tags = [
getNextAdjacentEdge(edge1),
getNextAdjacentEdge(edge2),
getNextAdjacentEdge(edge3),
getNextAdjacentEdge(edge4)
],
)
|> translate(x = 0, y = 50, z = 0)
// Create a spring by sweeping around a helix path from a cloned sketch.
// Create a helix around the Z axis.
helixPath = helix(
angleStart = 0,
ccw = true,
revolutions = 4,
length = 10,
radius = 5,
axis = Z,
)
springSketch = startSketchOn(YZ)
|> circle(center = [0, 0], radius = 1)
// Create a spring by sweeping around the helix path.
sweepedSpring = clone(springSketch)
|> translate(x = 100)
|> sweep(path = helixPath)
// A donut shape from a cloned sketch.
sketch001 = startSketchOn(XY)
|> circle(center = [15, 0], radius = 5)
sketch002 = clone(sketch001)
|> translate(z = 30)
|> revolve(angle = 360, axis = Y)
// Sketch on the end of a revolved face by tagging the end face.
// This shows the cloned geometry will have the same tags as the original geometry.
exampleSketch = startSketchOn(XY)
|> startProfileAt([4, 12], %)
|> line(end = [2, 0])
|> line(end = [0, -6])
|> line(end = [4, -6])
|> line(end = [0, -6])
|> line(end = [-3.75, -4.5])
|> line(end = [0, -5.5])
|> line(end = [-2, 0])
|> close()
example001 = revolve(
exampleSketch,
axis = Y,
angle = 180,
tagEnd = $end01,
)
// example002 = clone(example001)
// |> translate(x = 0, y = 20, z = 0)
// Sketch on the cloned face.
// exampleSketch002 = startSketchOn(example002, face = end01)
// |> startProfileAt([4.5, -5], %)
// |> line(end = [0, 5])
// |> line(end = [5, 0])
// |> line(end = [0, -5])
// |> close()
// example003 = extrude(exampleSketch002, length = 5)
// Clone an imported model.
import "tests/inputs/cube.sldprt" as cube
myCube = cube
clonedCube = clone(myCube)
|> translate(x = 1020)
|> appearance(color = "#ff0000", metalness = 50, roughness = 50)