1
0
Fork 0

feat(markdown): Documented cutlist store methods

This commit is contained in:
joostdecock 2023-10-29 17:44:35 +01:00
parent 283dec780d
commit 20aee31fb8
6 changed files with 114 additions and 190 deletions

View file

@ -115,162 +115,3 @@ To import the plugin for use:
import { plugin } from '@freesewing/plugin-annotations'
```
## Methods
### store.cutlist.addCut
The `store.cutlist.addCut()` method will add a set of cutting instructions for the part
#### Signature
```js
store.cutlist.addCut(Object so)
````
Pass an object to the `store.cutlist.addCut` method with any of the following keys; any you don't provide will be filled with the defaults:
| Key | Type | Default | Description |
| :-- | :--- | :------ | :---------- |
| cut | Number\|false | 2 | the number of pieces to cut from the specified material. Pass `false` to clear all cutting instructions for the material |
| material | String | 'fabric' | the translation key of the material to cut from |
| identical | Boolean | false | should even numbers of pieces be cut in the same direction? false for mirrored |
| bias | Boolean | false | should the pieces in these cutting instructions be cut on the bias |
| ignoreOnFold | Boolean | false | should these cutting instructions ignore any cutOnFold information set by the part |
<Note>
<details>
<summary> You can use any `string` you want for your material, but here are some standard ones we have translation for </summary>
<div>
| Key | Translation |
|:--|:--|
| fabric | Main Fabric |
| lining | Lining |
| canvas | Canvas |
| lmhCanavas | Light to Medium Hair Canvas |
| heavyCanvas | Heavyweight Hair Canvas |
| interfacing | Interfacing |
| plastic | Plastic |
| ribbing | Ribbing |
</div>
</details>
</Note>
#### Example
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
draft: ({part, store}) => {
// add instructions to cut two from main fabric
store.cutlist.addCut()
// add instructions to cut four on the bias from lining
store.cutlist.addCut({cut: 4, material: 'lining', bias: true, })
return part
}
}
```
You can also add multiple sets of cutting instructions for the same material
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
draft: ({part, store}) => {
// add instructions to 1 from lining
store.cutlist.addCut({cut: 1, material: 'lining'})
// add instructions to cut 1 on the bias from lining
store.cutlist.addCut({cut: 1, material: 'lining', bias: true, })
return part
}
}
```
### store.cutlist.removeCut
The `store.cutlist.removeCut()` method will remove cutting instructions from the part
#### Signature
```js
store.cutlist.removeCut(String material)
```
#### Example
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
draft: ({part, store}) => {
// remove all cutting instructions for all materials
store.cutlist.removeCut()
// remove cutting instructions for just one material
store.cutlist.removeCut('fabric')
return part
}
}
```
### store.cutlist.setGrain
The `store.cutlist.setGrain()` method will record the angle of the grainline annotation. This method is called internally by [`plugin-grainline`](/reference/plugins/grainline) to store information for cutting layout tools. You shouldn't have to call it, but it's there if you need it.
#### Signature
```js
store.cutlist.setGrain(Number grainAngle)
```
#### Example
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
draft: ({part, store}) => {
// set the grainline angle
store.cutlist.setGrain(0)
return part
}
}
```
### store.cutlist.setCutOnFold
The `store.cutlist.setCutOnFold()` method will record the points that make up the cut on fold line. This method is called internally by [`plugin-cutonfold`](/reference/plugins/cutonfold) to store information for cutting layout tools. You shouldn't have to call it, but it's there if you need it.
#### Signature
```js
store.cutlist.setCutOnFold(Point p1, Point p2)
```
#### Example
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
draft: ({part, points, Point, store}) => {
// set the cut on fold line
points.p1 = new Point(0, 0)
points.p2 = new Point(0, 10)
store.cutlist.setCutOnFold(points.p1, points.p2)
return part
}
}
```
## Notes
The annotations plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-annotations

View file

@ -1,31 +0,0 @@
---
title: removeMacroNodes()
---
Removes nodes generated by macro `id`.
By nodes, we mean paths, points, and so on that have been created by the macro.
When a macro properly uses a combination of `generateMacroIds()` and
`storeMacroIds()`, this method will fully handle its removal.
## Signature
```mjs
Object store.removeMacroNodes(
String id,
macro = store.activeMacro,
part = store.activePart,
)
```
The method takes a (macro) id and removes all nodes created by this macro,
It uses the active macro and part from the store, Or you can pass in `macro` and `part` to not use the active macro or part.
## Example
```mjs
undefined store.removeMacroNodes('macroId')
```

View file

@ -0,0 +1,67 @@
---
title: cutlist.addCut()
---
The `cutlist.addCut()` store method will add a set of cutting instructions for the part.
This information is not use by the core library, it is merely stored.
#### Signature
```js
undefined store.cutlist.addCut({
Number cut,
String from,
Bool identical = false,
Bool onBias = false,
Bool onFold = false,
})
````
Pass an object to the `store.cutlist.addCut` method with any of the following keys; any you don't provide will be filled with the defaults:
| Key | Type | Default | Description |
| :-- | :--- | :------ | :---------- |
| `cut` | Number\|false | 2 | The number of parts to cut from the specified material. Pass `false` to clear cutting instructions for the material |
| `from` | String | 'fabric' | The (translation key of the) material to cut from |
| `identical` | Boolean | false | Should even numbers of parts be cut in the same direction? The default (`false`) is to mirror them |
| `onBias` | Boolean | false | Should the parts be cut on the bias? |
| `onFold` | Boolean | false | Should the parts be cut on the fold? |
<Note>
You can use any `string` you want for your material, but here are some standard ones we provide translations for:
| Key | Translation |
|:--|:--|
| fabric | Main Fabric |
| lining | Lining |
| canvas | Canvas |
| interfacing | Interfacing |
| ribbing | Ribbing |
</Note>
#### Example
<Example caption="An example of the title macro">
```js
({ Point, Path, paths, macro, store, part }) => {
store.cutlist.addCut({cut: 2, from: 'fabric' })
store.cutlist.addCut({cut: 2, from: 'lining' })
macro('title', {
nr: 9,
title: 'The title',
at: new Point(0,0)
})
// Prevent clipping
paths.diag = new Path()
.move(new Point(-20,-50))
.move(new Point(80,35))
return part
}
```
</Example>

View file

@ -0,0 +1,19 @@
---
title: cutlist.removeCut()
---
The `store.cutlist.removeCut()` method will remove cutting instructions from the part for a given material.
#### Signature
```js
undefined cutlist.removeCut(String from)
```
## Example
```mjs
cutlist.removeCut('fabric')
```

View file

@ -0,0 +1,13 @@
---
title: cutlist.setCutOnFold()
---
The `cutlist.setCutOnFold()` method will take two points to determin the cut on fold line.
This method is called internally by [the `cutonfold` macro](/reference/macros/cutonfold) to store information for cutting layout tools.
In other words, you typically have no reason to call this method manually.
#### Signature
```js
undefined cutlist.setCutOnFold(Point p1, Point p2)
```

View file

@ -0,0 +1,15 @@
---
title: cutlist.setGrain()
---
The `store.cutlist.setGrain()` method will take an angle to determin the grainline.
This method is called internally by [the `grainline` macro](/reference/macros/grainline).
to store information for cutting layout tools.
In other words, you typically have no reason to call this method manually.
#### Signature
```js
undefined store.cutlist.setGrain(Number grainAngle)
```