2021-10-17 18:26:00 +02:00
|
|
|
---
|
2023-09-28 09:11:06 +02:00
|
|
|
title: Creating a part
|
2024-11-18 11:05:16 +01:00
|
|
|
sidebar_position: 20
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-02-20 14:35:50 +01:00
|
|
|
Much like garments themselves, patterns are made up of _parts_.
|
2022-10-09 23:47:32 +02:00
|
|
|
Most patterns will have multiple parts. A sleeve, a back part, the collar, and
|
2023-09-28 09:11:06 +02:00
|
|
|
so on. The pattern you create today is very simple, and only has one part: the bib.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::tip
|
2023-09-28 09:11:06 +02:00
|
|
|
|
2024-11-18 11:05:16 +01:00
|
|
|
It's a good idea to keep each part in its own file. You don't _have to_ do
|
|
|
|
this, but it's a good habit to get into.
|
2023-09-28 09:11:06 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-09 23:47:32 +02:00
|
|
|
## bib.mjs
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-11-18 11:05:16 +01:00
|
|
|
I am going to use the **From scratch** template. So the files I want to edit live
|
2023-09-30 14:04:18 +02:00
|
|
|
in `design/from-scratch`.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2023-09-30 14:04:18 +02:00
|
|
|
Our part lives in `design/from-scratch/src/bib.mjs`, and it currently looks like this:
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2023-09-30 14:04:18 +02:00
|
|
|
```src/bib.mjs
|
|
|
|
function draftBib({ part }) {
|
2022-10-09 23:47:32 +02:00
|
|
|
return part
|
|
|
|
}
|
2023-08-08 13:20:46 -05:00
|
|
|
|
2023-09-28 09:11:06 +02:00
|
|
|
export const bib = {
|
2023-09-30 14:04:18 +02:00
|
|
|
name: 'fromscratch.bib',
|
2023-09-28 09:11:06 +02:00
|
|
|
draft: draftBib,
|
2022-10-09 23:47:32 +02:00
|
|
|
}
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
2022-02-19 08:04:25 +01:00
|
|
|
|
2023-09-30 14:04:18 +02:00
|
|
|
## The part object
|
2021-08-25 16:16:51 +02:00
|
|
|
|
2023-09-28 09:11:06 +02:00
|
|
|
Each part in FreeSewing is an object that describes the part, and has a `draft`
|
|
|
|
method to do the actual work of drafting the part.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-09 23:47:32 +02:00
|
|
|
The only mandatory keys on a part object are `name` and `draft`.
|
2022-02-19 08:04:25 +01:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::note RELATED
|
2023-09-28 09:11:06 +02:00
|
|
|
|
2024-11-18 11:05:16 +01:00
|
|
|
Refer to [the part reference documentation](/reference/api/part) for
|
|
|
|
all details about configuring the part object
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::note
|
2023-09-28 09:11:06 +02:00
|
|
|
|
|
|
|
A design in FreeSewing is a thin wrapper around a collection of parts.
|
|
|
|
Each parts stands on its own, and parts from various designs can be combined
|
|
|
|
to create other designs.
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2023-09-28 09:11:06 +02:00
|
|
|
|
2023-09-30 14:04:18 +02:00
|
|
|
### The part name
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2023-09-30 14:04:18 +02:00
|
|
|
```src/bib.mjs
|
|
|
|
name: 'fromscratch.bib',
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
2023-09-30 14:04:18 +02:00
|
|
|
A part's `name` should be unique in a design. I used `fromscratch.bib` as the
|
2023-09-28 09:11:06 +02:00
|
|
|
name, because that makes sense.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::warning
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2023-09-28 09:11:06 +02:00
|
|
|
I **strongly** recommend that you apply the same `designName.partName` naming scheme in all your parts.
|
|
|
|
This avoids naming conflicts when mixing parts from various designs to create a new design.
|
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2023-09-30 14:04:18 +02:00
|
|
|
### The part's draft method
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2023-09-30 14:04:18 +02:00
|
|
|
```src/bib.mjs
|
2022-10-09 23:47:32 +02:00
|
|
|
draft: draftBib,
|
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-09 23:47:32 +02:00
|
|
|
The second mandatory key on the part object is `draft` which should hold the method that drafts the part.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2023-09-28 09:11:06 +02:00
|
|
|
In the example above, it refers to the `draftBib` function that was defined at the top of the same `bib.mjs` file.
|
|
|
|
|
2022-10-09 23:47:32 +02:00
|
|
|
For now this function doesn't do much, but that will change soon enough.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::note
|
2022-10-09 23:47:32 +02:00
|
|
|
This structure of putting the draft method at the top of the file and
|
2023-01-06 19:29:29 -08:00
|
|
|
the part object at the bottom is a bit of a convention in FreeSewing.
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-03-12 02:02:06 +00:00
|
|
|
We'll take a deeper look at our part's draft method soon. For now, let's look at adding measurements to our part.
|