2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
title: Part
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-20 18:09:28 +02:00
|
|
|
A `Part` in FreeSewing holds all data, logic, and configuration of a Design.
|
|
|
|
Parts truly are the building blocks of FreeSewing as they not only provide
|
2022-12-14 12:52:37 -08:00
|
|
|
the configuration, but also a `draft()` method that does the actual work
|
2022-09-20 18:09:28 +02:00
|
|
|
of drafting a parametric design.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-02-09 07:23:08 -08:00
|
|
|
## Properties
|
|
|
|
|
|
|
|
A Part object comes with the following properties:
|
|
|
|
|
|
|
|
- `attributes` : An [Attributes](/reference/api/attributes) instance holding
|
|
|
|
the part's attributes
|
2024-02-11 06:07:51 -08:00
|
|
|
- `hidden` : When this is `true` the part will be hidden (excluding it from the
|
2024-02-09 07:23:08 -08:00
|
|
|
output). See [Part.hide()](/reference/api/part/hide),
|
|
|
|
[Part.unhide()](/reference/api/part/unhide), and
|
|
|
|
[Part.setHidden()](/reference/api/part/sethidden) for various methods that
|
|
|
|
allow setting this in a chainable way.
|
|
|
|
- `name` : The name of the part
|
|
|
|
- `paths` : Holds the paths used in the part
|
|
|
|
- `points` : Holds the points used in the part
|
|
|
|
- `snippets` : Holds the snippets used in the part
|
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::note RELATED
|
2024-02-09 07:23:08 -08:00
|
|
|
See [Using Attributes](/howtos/code/attributes)
|
|
|
|
for information about custom Attributes that can be used with Parts.
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2024-02-09 07:23:08 -08:00
|
|
|
|
2022-09-21 09:55:21 +02:00
|
|
|
## Example
|
2022-09-20 18:09:28 +02:00
|
|
|
|
|
|
|
```js
|
2022-09-21 09:55:21 +02:00
|
|
|
const part = {
|
|
|
|
name: 'example.part',
|
|
|
|
from: otherPart,
|
|
|
|
after: [ yetAnotherPart, oneMorePart ],
|
|
|
|
measurements: ['head', 'chest' ],
|
|
|
|
optionalMeasurements: ['neck'],
|
|
|
|
options: {
|
|
|
|
headEase: { pct: 12, min: 5, max: 20 }
|
|
|
|
}
|
|
|
|
hide: false,
|
|
|
|
hideAll: false,
|
|
|
|
hideDependencies: true,
|
|
|
|
plugins: [
|
|
|
|
plugin1,
|
|
|
|
plugin1,
|
|
|
|
[ plugin3, dataForPlugin3 ],
|
2022-10-09 23:47:58 +02:00
|
|
|
],
|
|
|
|
draft: ({ part }) => part
|
2022-09-21 09:55:21 +02:00
|
|
|
}
|
2022-09-20 18:09:28 +02:00
|
|
|
```
|
|
|
|
|
2024-02-09 07:23:08 -08:00
|
|
|
## Methods
|
|
|
|
|
|
|
|
A Part object exposes the following methods:
|
|
|
|
|
|
|
|
- [Part.asRenderProps()](/reference/api/part/asrenderprops)
|
|
|
|
- [Part.attr()](/reference/api/part/attr)
|
|
|
|
- [Part.getId()](/reference/api/part/getid)
|
|
|
|
- [Part.hide()](/reference/api/part/hide)
|
|
|
|
- [Part.setHidden()](/reference/api/part/sethidden)
|
|
|
|
- [Part.shorthand()](/reference/api/part/shorthand)
|
|
|
|
- [Part.unhide()](/reference/api/part/unhide)
|
|
|
|
- [Part.units()](/reference/api/part/units)
|
|
|
|
|
|
|
|
## More information
|
|
|
|
|
2022-09-21 09:55:21 +02:00
|
|
|
Click below to learn more about:
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-21 09:55:21 +02:00
|
|
|
- [A part's configuration](/reference/api/part/config)
|
|
|
|
- [A part's `draft()` method](/reference/api/part/draft)
|