kcl

translate

Move a solid or a sketch.

translate(
  objects: SolidOrSketchOrImportedGeometry,
  translate: [number],
  global?: bool,
): SolidOrSketchOrImportedGeometry

Arguments

NameTypeDescriptionRequired
objectsSolidOrSketchOrImportedGeometryThe solid, sketch, or set of solids or sketches to move.Yes
translate[number]The amount to move the solid or sketch in all three axes.Yes
globalboolIf true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move.No

Returns

SolidOrSketchOrImportedGeometry - Data for a solid or an imported geometry.

Examples

// Move a pipe.

// Create a path for the sweep.
sweepPath = startSketchOn(XZ)
  |> startProfileAt([0.05, 0.05], %)
  |> line(end = [0, 7])
  |> tangentialArc({ offset = 90, radius = 5 }, %)
  |> line(end = [-3, 0])
  |> tangentialArc({ offset = -90, radius = 5 }, %)
  |> line(end = [0, 7])

// Create a hole for the pipe.
pipeHole = startSketchOn(XY)
  |> circle(center = [0, 0], radius = 1.5)

sweepSketch = startSketchOn(XY)
  |> circle(center = [0, 0], radius = 2)
  |> hole(pipeHole, %)
  |> sweep(path = sweepPath)
  |> translate(translate = [1.0, 1.0, 2.5])

Rendered example of translate 0

// Move an imported model.


import "tests/inputs/cube.sldprt" as cube

cube
  |> translate(translate = [1.0, 1.0, 2.5])

Rendered example of translate 1

// Sweep two sketches along the same path.


sketch001 = startSketchOn(XY)
rectangleSketch = startProfileAt([-200, 23.86], sketch001)
  |> angledLine([0, 73.47], %, $rectangleSegmentA001)
  |> angledLine([
       segAng(rectangleSegmentA001) - 90,
       50.61
     ], %)
  |> angledLine([
       segAng(rectangleSegmentA001),
       -segLen(rectangleSegmentA001)
     ], %)
  |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
  |> close()

circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)

sketch002 = startSketchOn(YZ)
sweepPath = startProfileAt([0, 0], sketch002)
  |> yLine(length = 231.81)
  |> tangentialArc({ radius = 80, offset = -90 }, %)
  |> xLine(length = 384.93)

parts = sweep([rectangleSketch, circleSketch], path = sweepPath)

// Move the sweeps.
translate(parts, translate = [1.0, 1.0, 2.5])

Rendered example of translate 2

// Move a sketch.


fn square(length) {
  l = length / 2
  p0 = [-l, -l]
  p1 = [-l, l]
  p2 = [l, l]
  p3 = [l, -l]

  return startSketchOn(XY)
    |> startProfileAt(p0, %)
    |> line(endAbsolute = p1)
    |> line(endAbsolute = p2)
    |> line(endAbsolute = p3)
    |> close()
}

square(10)
  |> translate(translate = [5, 5, 0])
  |> extrude(length = 10)

Rendered example of translate 3

// Translate and rotate a sketch to create a loft.
sketch001 = startSketchOn(XY)

fn square() {
  return startProfileAt([-10, 10], sketch001)
    |> xLine(length = 20)
    |> yLine(length = -20)
    |> xLine(length = -20)
    |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
    |> close()
}

profile001 = square()

profile002 = square()
  |> translate(translate = [0, 0, 20])
  |> rotate(axis = [0, 0, 1.0], angle = 45)

loft([profile001, profile002])

Rendered example of translate 4