fix(markdown): Restructure part reference. See #2981
This commit is contained in:
parent
b4eb7e7b00
commit
ac7b5befce
10 changed files with 105 additions and 110 deletions
37
markdown/dev/reference/api/part/getid/en.md
Normal file
37
markdown/dev/reference/api/part/getid/en.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
title: Part.getId()
|
||||
---
|
||||
|
||||
The `Part.getId()` methid will return an integer the can be used as an
|
||||
for ID Points/Paths/Snippets. This method will ensure the ID is unique by
|
||||
keeping an internal incremental counter of the IDs that have been used.
|
||||
It is typically used when programatically adding points, paths, or snippets.
|
||||
|
||||
<Tip>
|
||||
This method can be destructured as `getID`
|
||||
in [a part's draft method](/reference/api/part/draft).
|
||||
</Tip>
|
||||
|
||||
|
||||
## Part.getId() signature
|
||||
|
||||
```js
|
||||
int|string getId(prefix='')
|
||||
```
|
||||
|
||||
This methiod takes an optional parameter that will be used as a prefix for the ID.
|
||||
|
||||
## Part.getId() example
|
||||
|
||||
```js
|
||||
cont part = {
|
||||
name: 'examples.getid',
|
||||
draft: ({ Point, points, getId, part }) => {
|
||||
for (let i=0;i<10;i++) {
|
||||
points[getId()] = new Point(i*10, i*10)
|
||||
}
|
||||
|
||||
return part
|
||||
}
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue