* Automatic fixing of deprecations and use non-quoted default planes by default Signed-off-by: Nick Cameron <nrc@ncameron.org> * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 --------- Signed-off-by: Nick Cameron <nrc@ncameron.org> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
		
			
				
	
	
		
			52 lines
		
	
	
		
			52 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			52 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
---
 | 
						|
title: "patternTransform2d"
 | 
						|
excerpt: "Just like patternTransform, but works on 2D sketches not 3D solids."
 | 
						|
layout: manual
 | 
						|
---
 | 
						|
 | 
						|
Just like patternTransform, but works on 2D sketches not 3D solids.
 | 
						|
 | 
						|
 | 
						|
 | 
						|
```js
 | 
						|
patternTransform2d(
 | 
						|
  sketches: [Sketch],
 | 
						|
  instances: integer,
 | 
						|
  transform: FunctionSource,
 | 
						|
  useOriginal?: bool,
 | 
						|
): [Sketch]
 | 
						|
```
 | 
						|
 | 
						|
 | 
						|
### Arguments
 | 
						|
 | 
						|
| Name | Type | Description | Required |
 | 
						|
|----------|------|-------------|----------|
 | 
						|
| `sketches` | [`[Sketch]`](/docs/kcl/types/Sketch) | The sketch(es) to duplicate | Yes |
 | 
						|
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
 | 
						|
| `transform` | `FunctionSource` | How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples. | Yes |
 | 
						|
| `useOriginal` | [`bool`](/docs/kcl/types/bool) | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
 | 
						|
 | 
						|
### Returns
 | 
						|
 | 
						|
[`[Sketch]`](/docs/kcl/types/Sketch)
 | 
						|
 | 
						|
 | 
						|
### Examples
 | 
						|
 | 
						|
```js
 | 
						|
// Each instance will be shifted along the X axis.
 | 
						|
fn transform(id) {
 | 
						|
  return { translate = [4 * id, 0] }
 | 
						|
}
 | 
						|
 | 
						|
// Sketch 4 circles.
 | 
						|
sketch001 = startSketchOn(XZ)
 | 
						|
  |> circle(center = [0, 0], radius = 2)
 | 
						|
  |> patternTransform2d(instances = 4, transform = transform)
 | 
						|
```
 | 
						|
 | 
						|

 | 
						|
 | 
						|
 |