2021-10-17 18:26:00 +02:00
|
|
|
---
|
|
|
|
title: pd
|
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-30 04:39:30 +02:00
|
|
|
The `pd` macro adds a _path dimension_ to your pattern, indicating the length
|
|
|
|
of a path. It is provided by the [dimension
|
|
|
|
plugin](/reference/plugins/dimension/).
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-30 04:39:30 +02:00
|
|
|
## Signature
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
macro('pd', {
|
2022-09-30 04:39:30 +02:00
|
|
|
Number d,
|
|
|
|
String id,
|
|
|
|
Path path,
|
2022-12-09 20:59:53 -08:00
|
|
|
Boolean noEndMarker,
|
2022-09-30 04:39:30 +02:00
|
|
|
Boolean noStartMarker,
|
|
|
|
String text,
|
2021-08-25 16:09:31 +02:00
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2022-09-30 04:39:30 +02:00
|
|
|
## Example
|
|
|
|
|
|
|
|
<Example caption="An example of a path dimension with the pd macro">
|
|
|
|
```js
|
|
|
|
({ Point, Path, paths, macro, part }) => {
|
|
|
|
|
|
|
|
paths.example = new Path()
|
|
|
|
.move(new Point(0,0))
|
|
|
|
.curve(new Point(20,10), new Point(60,10), new Point(80,0))
|
|
|
|
|
|
|
|
macro('pd', {
|
|
|
|
path: paths.example,
|
|
|
|
d: 15,
|
|
|
|
})
|
|
|
|
|
|
|
|
return part
|
|
|
|
}
|
|
|
|
```
|
|
|
|
</Example>
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
2022-02-19 08:04:25 +01:00
|
|
|
| Property | Default | Type | Description |
|
2021-08-25 16:09:31 +02:00
|
|
|
|----------------:|---------|---------------------|-------------|
|
|
|
|
| `path` | | [Path](/reference/api/path) | The path to draw the dimension along |
|
2022-12-09 20:59:53 -08:00
|
|
|
| `d` | 10 | Number | The offset at which to draw the dimension |
|
2021-08-25 16:09:31 +02:00
|
|
|
| `text` | Path length | Number | The text to go on the dimension if not the length of the path |
|
2022-12-09 20:59:53 -08:00
|
|
|
| `id` | auto-assigned | String | A custom ID under which paths and points will be created |
|
2021-08-25 16:09:31 +02:00
|
|
|
| `noStartMarker` | `false` | Boolean | Whether to not draw a start marker |
|
2022-01-18 08:31:04 +01:00
|
|
|
| `noEndMarker` | `false` | Boolean | Whether to not draw an end marker |
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-09 20:59:53 -08:00
|
|
|
## Result
|
|
|
|
|
|
|
|
| Generated Element | Description |
|
|
|
|
|-------------------|-------------|
|
|
|
|
| `paths.${id}` | Path for the span of the dimension |
|
|
|
|
| `paths.${id}_ls` | Path for the leader to the start of the dimension |
|
|
|
|
| `paths.${id}_le` | Path for the leader to the end of the dimension |
|
|
|
|
|
2022-09-30 04:39:30 +02:00
|
|
|
## Notes
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
Setting a custom ID will:
|
|
|
|
|
2022-02-20 14:44:38 +01:00
|
|
|
- Allow removal of the dimension with [the `rmd` macro](/reference/macros/rmd)
|
|
|
|
- Prevent removal of the dimension with [the `rmad` macro](/reference/macros/rmad/)
|