* update pattern entity ids since that pr merged Signed-off-by: Jess Frazelle <github@jessfraz.com> * artifacts Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
		
			
				
	
	
	
		
			540 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			540 KiB
		
	
	
	
	
	
	
	
title, subtitle, excerpt, layout
| title | subtitle | excerpt | layout | 
|---|---|---|---|
| translate | Function in std::transform | Move a solid or a sketch. | manual | 
Move a solid or a sketch.
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] or [Sketch] or ImportedGeometry | 
The solid, sketch, or set of solids or sketches to move. | Yes | 
x | 
number | 
The amount to move the solid or sketch along the x axis. Defaults to 0 if not provided. | No | 
y | 
number | 
The amount to move the solid or sketch along the y axis. Defaults to 0 if not provided. | No | 
z | 
number | 
The amount to move the solid or sketch along the z axis. Defaults to 0 if not provided. | No | 
global | 
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] or [Sketch] or ImportedGeometry - Data for a solid, sketch, or an imported geometry.
Examples
// 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)
// 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)
// 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,
)
// 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)
// 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])