diff --git a/markdown/dev/howtos/design/cutlist/en.md b/markdown/dev/howtos/design/cutlist/en.md new file mode 100644 index 00000000000..eb52e7c2895 --- /dev/null +++ b/markdown/dev/howtos/design/cutlist/en.md @@ -0,0 +1,150 @@ +--- +title: "Include Cutting Instructions" +--- + +To include cutting instructions with your part, use the [cutlist plugin](/reference/plugins/cutlist) to add the [`addCut` method](/reference/plugins/cutlist#addcut) to your part's [`draft` method](/reference/api/part/draft) + +When you use the cutlist plugin, the [grainline plugin](/reference/plugins/grainline) and the [cut on fold plugin](/reference/plugins/cutonfold) will automatically add grain and fold information to the cutting instructions + +These cutting instructions get used by the [title macro](/reference/macros/title), so be sure to add them before adding your part's title. + + +
+ addCut() Parameters + +Pass an object to the `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 | + + +You can use any `string` you want for your material, but here are some standard ones we have translation for + +| 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 | + +
+
+ + +## Basic Usage +For simple cutting instructions, you can rely on the default method parameters + +```js +import {pluginCutlist} from '@freesewing/plugin-cutlist' + +const part = { + name: 'example.front', + plugins: [pluginCutlist], + draft: ({part, addCut}) => { + // add instructions to cut two mirrored from main fabric + addCut() + } +} +``` + +## Intermediate Usage +For many designs, you'll want more than just "Cut 2 mirrored from Main Fabric" + +### Specifying materials, number of pieces, orientation + +You can override the default values to specify different materials, number of pieces to cut, and whether they should be mirrored or identical + +```js +import {pluginCutlist} from '@freesewing/plugin-cutlist' + +const part = { + name: 'example.front', + plugins: [pluginCutlist], + draft: ({part, addCut}) => { + // add instructions to cut three identical from lining + addCut({cut: 3, material: 'lining', identical: true}) + } +} +``` + +### Instructions for multiple materials +You can add as many sets of instructions as you need + +```js +import {pluginCutlist} from '@freesewing/plugin-cutlist' + +const part = { + name: 'example.front', + plugins: [pluginCutlist], + draft: ({part, addCut}) => { + // add instructions to cut four mirrored from main fabric + addCut({cut: 4}) + // add instructions to cut three identical from lining + addCut({cut: 3, material: 'lining', identical: true}) + } +} +``` + +## Advanced usage + +### Cut some on the fold, some not +Sometimes you want some pieces cut on the fold and others cut as halves to seam together. + +```js +import {pluginCutlist} from '@freesewing/plugin-cutlist' +import {pluginCutonfold} from '@freesewing/plugin-cutonfold' + +const part = { + name: 'example.front', + plugins: [pluginCutlist, pluginCutonfold], + draft: ({part, points, Point, macro, addCut}) => { + // set the cut on fold line + points.p1 = new Point(0, 0) + points.p2 = new Point(0, 10) + + // pieces should be cut on the fold + macro('cutonfold', {from: points.p1, to: points.p2}) + + // cut two on the fold + addCut() + // cut two, not on the fold + addCut({cut: 2, ignoreOnFold: true}) + } +} +``` + + +### Cut some on the grain, some on the bias +You set the grainline on a piece, but you also need some to be cut on the bias + +```js +import {pluginCutlist} from '@freesewing/plugin-cutlist' +import {pluginGrainline} from '@freesewing/plugin-grainline' + +const part = { + name: 'example.front', + plugins: [pluginCutlist, pluginGrainline], + draft: ({part, points, Point, macro, addCut}) => { + // set the cut on fold line + points.p1 = new Point(0, 0) + points.p2 = new Point(0, 10) + + // the grain runs from p1 to p2 + macro('grainline', {from: points.p1, to: points.p2}) + + // cut two mirrored on the grain + addCut() + // cut two mirrored on the bias + addCut({cut: 2, bias: true}) + } +} +``` diff --git a/markdown/dev/reference/api/part/draft/en.md b/markdown/dev/reference/api/part/draft/en.md index c9936bf1771..3a3f7943538 100644 --- a/markdown/dev/reference/api/part/draft/en.md +++ b/markdown/dev/reference/api/part/draft/en.md @@ -46,4 +46,4 @@ access the following properties: || **_Return value_** | | `part` | Your draft method **must** return this | - + Some plugins, such as the [cutlist plugin](/reference/plugins/cutlist) add additional methods to this object that can be accessed through the same destructuring diff --git a/markdown/dev/reference/plugins/cutlist/en.md b/markdown/dev/reference/plugins/cutlist/en.md new file mode 100644 index 00000000000..6d739c494e0 --- /dev/null +++ b/markdown/dev/reference/plugins/cutlist/en.md @@ -0,0 +1,188 @@ +--- +title: plugin-cutlist +--- + +Published as [@freesewing/plugin-cutlist][1], this plugin provides additional methods to the [part draft function](/reference/api/part/draft) which allow you to configure cutting instructions for your parts. + + For an in-depth look at how to add cutting instructions to your part, see our [cutlist how-to](/howtos/design/cutlist) + +## Installation + +```sh +npm install @freesewing/plugin-cutonfold +``` + +## Usage + +Either [add it as a part plugin](/reference/api/part/config/plugins) in your +design, or [add it to a pattern instance with +Pattern.use()](/reference/api/pattern/use). + +To import the plugin for use: +```js +import { cutlistPlugin } from '@freesewing/plugin-cutlist' +// or +import { pluginCutlist } from '@freesewing/plugin-cutlist' +``` + +## Methods + +The cutlist plugin adds the following methods to the part draft method parameter + +### addCut + +The `addCut()` method will add a set of cutting instructions for the part + +#### Signature +```js +addCut(Object so) +```` + +Pass an object to the `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 | + + +
+ You can use any `string` you want for your material, but here are some standard ones we have translation for +
+ +| 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 | + +
+
+
+ +#### Example + +```js +import {pluginCutlist} from '@freesewing/plugin-cutlist' + +const part = { + name: 'example.front', + plugins: [pluginCutlist], + draft: ({part, addCut}) => { + // add instructions to cut two from main fabric + addCut() + // add instructions to cut four on the biad from lining + 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, addCut}) => { + // add instructions to 1 from lining + addCut({cut: 1, material: 'lining'}) + // add instructions to cut 1 on the bias from lining + addCut({cut: 1, material: 'lining', bias: true, }) + return part + } +} +``` + +### removeCut + +The `removeCut()` method will remove cutting instructions from the part + +#### Signature + +```js +removeCut(String material) +``` + +#### Example +```js +import {pluginCutlist} from '@freesewing/plugin-cutlist' + +const part = { + name: 'example.front', + plugins: [pluginCutlist], + draft: ({part, removeCut}) => { + // remove all cutting instructions for all materials + removeCut() + + // remove cutting instructions for just one material + removeCut('fabric') + return part + } +} +``` +### setGrain + +The `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 +setGrain(Number grainAngle) +``` + +#### Example +```js +import {pluginCutlist} from '@freesewing/plugin-cutlist' + +const part = { + name: 'example.front', + plugins: [pluginCutlist], + draft: ({part, setGrain}) => { + // set the grainline angle + setGrain(0) + return part + } +} +``` + +### setCutOnFold +The `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 +setCutOnFold(Point p1, Point p2) +``` + +#### Example +```js +import {pluginCutlist} from '@freesewing/plugin-cutlist' + +const part = { + name: 'example.front', + plugins: [pluginCutlist], + draft: ({part, points, Point, setCutOnFold}) => { + // set the cut on fold line + points.p1 = new Point(0, 0) + points.p2 = new Point(0, 10) + setCutOnFold(points.p1, points.p2) + return part + } +} +``` + +## Notes + +The cutlist plugin is part of our [plugin-bundle](/reference/plugins/bundle) + +[1]: https://www.npmjs.com/package/@freesewing/plugin-cutlist diff --git a/plugins/plugin-cutlist/src/index.mjs b/plugins/plugin-cutlist/src/index.mjs index 388a8f0a8a9..9ff14095d57 100644 --- a/plugins/plugin-cutlist/src/index.mjs +++ b/plugins/plugin-cutlist/src/index.mjs @@ -9,7 +9,6 @@ export const plugin = { ['removeCut', removeCut], ['setGrain', setGrain], ['setCutOnFold', setCutOnFold], - ['getCutOnFold', getCutOnFold], ], } @@ -17,7 +16,17 @@ export const plugin = { export const cutlistPlugin = plugin export const pluginCutlist = plugin -/** Method to add the cut info */ +/** + * Add a set of cutting instructions for the part + * @param {Store} store the Store + * @param {string} partName the name of the part + * @param {Object} so a set of cutting instructions for a material + * @param {number} so.cut = 2 the number of pieces to cut from the specified fabric + * @param {string} so.material = fabric the name of the material to cut from + * @param {boolean} so.identical = false should even numbers of pieces be cut in the same direction or mirrored + * @param {boolean} so.bias = false should the pieces in these cutting instructions be cut on the bias + * @param {boolean} so.ignoreOnFold should these cutting instructions ignore any cutOnFold information set by the part + */ function addCut(store, partName, so = {}) { const { cut = 2, material = 'fabric', identical = false, bias = false, ignoreOnFold = false } = so if (cut === false) { @@ -36,7 +45,6 @@ function addCut(store, partName, so = {}) { const path = ['cutlist', partName, 'materials', material] const existing = store.get(path) || [] store.set(path, existing.concat({ cut, identical, bias, ignoreOnFold })) - // store.set([...path, 'identical'], identical) return store } @@ -70,11 +78,3 @@ function setCutOnFold(store, partName, p1, p2) { return store } - -function getCutOnFold(store, partName, material = false) { - const partFold = store.get(['cutlist', partName, 'cutOnFold']) - if (!material) return partFold - - const matFold = store.get(['cutlist', partName, 'materials', material, 'cutOnFold']) - return matFold === undefined ? partFold : matFold -}