KCL Library Referencestdclone

cloneFunction in std

Clone a sketch or solid.

clone(@geometry: Sketch | Solid | ImportedGeometry): Sketch | Solid | ImportedGeometry

This works essentially like a copy-paste operation. It creates a perfect replica at that point in time that you can manipulate individually afterwards.

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.

Arguments

NameTypeDescriptionRequired
geometrySketch or Solid or ImportedGeometryThe sketch, solid, or imported geometry to be cloned.Yes

Returns

Sketch or Solid or ImportedGeometry

Examples

// Clone a basic sketch and move it and extrude it.
exampleSketch = startSketchOn(XY)
  |> startProfile(at = [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)

Rendered example of clone 0

// Clone a basic solid and move it.

exampleSketch = startSketchOn(XY)
  |> startProfile(at = [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,
    )

Rendered example of clone 1

// Translate and rotate a cloned sketch to create a loft.

sketch001 = startSketchOn(XY)
        |> startProfile(at = [-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])

Rendered example of clone 2

// Translate a cloned solid. Fillet only the clone.

sketch001 = startSketchOn(XY)
        |> startProfile(at = [-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)],
    )

Rendered example of clone 3

// You can reuse the tags from the original geometry with the cloned geometry.

sketch001 = startSketchOn(XY)
  |> startProfile(at = [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)
  |> startProfile(at = [1, 1])
  |> line(end = [8, 0])
  |> line(end = [0, 8])
  |> line(end = [-8, 0])
  |> close(tag = $sketchingFace002)
  |> extrude(length = 10)

Rendered example of clone 4

// 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)
  |> startProfile(at = [-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)

Rendered example of clone 5

// 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(XZ)
    |> circle( center = [0, 0], radius = 1)

// Create a spring by sweeping around the helix path.
sweepedSpring = clone(springSketch)
    |> translate(x=5)
    |> sweep(path = helixPath)

Rendered example of clone 6

// 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,
    )

Rendered example of clone 7

// 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)
  |> startProfile(at = [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)
//  |> startProfile(at = [4.5, -5])
//  |> line(end = [0, 5])
//  |> line(end = [5, 0])
//  |> line(end = [0, -5])
//  |> close()

// example003 = extrude(exampleSketch002, length = 5)

Rendered example of clone 8

// 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
   )

Rendered example of clone 9