---
title: "translate"
subtitle: "Function in std::transform"
excerpt: "Move a solid or a sketch."
layout: manual
---

Move a solid or a sketch.

```kcl
translate(
  @objects: [Solid] | [Sketch] | ImportedGeometry,
  x?: number,
  y?: number,
  z?: number,
  global?: bool,
): [Solid] | [Sketch] | ImportedGeometry
```

This is really useful for assembling parts together. You can create a part and then move it to the correct location.

Translate is really useful for sketches if you want to move a sketch and then rotate it using the `rotate` function to create a loft.

### Arguments

| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `objects` | [`[Solid]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) | The solid, sketch, or set of solids or sketches to move. | Yes |
| `x` | [`number`](/docs/kcl-std/types/std-types-number) | The amount to move the solid or sketch along the x axis. Defaults to 0 if not provided. | No |
| `y` | [`number`](/docs/kcl-std/types/std-types-number) | The amount to move the solid or sketch along the y axis. Defaults to 0 if not provided. | No |
| `z` | [`number`](/docs/kcl-std/types/std-types-number) | The amount to move the solid or sketch along the z axis. Defaults to 0 if not provided. | No |
| `global` | [`bool`](/docs/kcl-std/types/std-types-bool) | If 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

[`[Solid]`](/docs/kcl-std/types/std-types-Solid) or [`[Sketch]`](/docs/kcl-std/types/std-types-Sketch) or [`ImportedGeometry`](/docs/kcl-std/types/std-types-ImportedGeometry) - Data for a solid, sketch, or an imported geometry.


### Examples

```kcl
// Move a pipe.

// Create a path for the sweep.
sweepPath = startSketchOn(XZ)
  |> startProfile(at = [0.05, 0.05])
  |> line(end = [0, 7])
  |> tangentialArc(angle = 90, radius = 5)
  |> line(end = [-3, 0])
  |> tangentialArc(angle = -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)
  |> subtract2d(tool = pipeHole)
  |> sweep(path = sweepPath)
  |> translate(x = 1.0, y = 1.0, z = 2.5)
```

![Rendered example of translate 0](data:image/png;base64,[encoded data, 98684 characters])

```kcl
// Move an imported model.


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

// Circle so you actually see the move.
startSketchOn(XY)
  |> circle(center = [-10, -10], radius = 10)
  |> extrude(length = 10)

cube
  |> translate(x = 10.0, y = 10.0, z = 2.5)
```

![Rendered example of translate 1](data:image/png;base64,[encoded data, 100732 characters])

```kcl
// Sweep two sketches along the same path.


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

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

sketch002 = startSketchOn(YZ)
sweepPath = startProfile(sketch002, at = [0, 0])
  |> yLine(length = 231.81)
  |> tangentialArc(radius = 80, angle = -90)
  |> xLine(length = 384.93)

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

// Move the sweeps.
translate(
  parts,
  x = 1.0,
  y = 1.0,
  z = 2.5,
)
```

![Rendered example of translate 2](data:image/png;base64,[encoded data, 120552 characters])

```kcl
// Move a sketch.


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

  return startSketchOn(XY)
    |> startProfile(at = p0)
    |> line(endAbsolute = p1)
    |> line(endAbsolute = p2)
    |> line(endAbsolute = p3)
    |> close()
}

square(10)
  |> translate(x = 5, y = 5)
  |> extrude(length = 10)
```

![Rendered example of translate 3](data:image/png;base64,[encoded data, 111348 characters])

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

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

profile001 = square()

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

loft([profile001, profile002])
```

![Rendered example of translate 4](data:image/png;base64,[encoded data, 116612 characters])


