2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
title: Part inheritance
|
|
|
|
for: developers
|
|
|
|
about: Shows how you can use one part of your pattern as the basis for another
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
Part inheritance within your own pattern is handled via the `inject` settings in
|
|
|
|
the [pattern configuration](/reference/config/). Here is a simple example:
|
|
|
|
|
|
|
|
```js
|
|
|
|
inject: {
|
|
|
|
front: "base",
|
|
|
|
back: "base",
|
|
|
|
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-17 18:26:00 +02:00
|
|
|
The `front` and `back` parts will be *injected* with the `base` part. As a result, both
|
|
|
|
the `front` and `back` parts will be instantiated with a cloned copy of all the points, paths,
|
2021-08-25 16:09:31 +02:00
|
|
|
and snippets of the `base` part.
|
|
|
|
|
|
|
|
This is a common design pattern where one part builds on another. In our example, we can imagine
|
|
|
|
a T-shirt pattern where the front and back are rather similar, apart from the neckline.
|
2021-10-17 18:26:00 +02:00
|
|
|
So rather than repeating ourselves, we draft a `base` part and inject that in the `front` and
|
2021-08-25 16:09:31 +02:00
|
|
|
`back` parts.
|
|
|
|
|
2021-10-17 18:26:00 +02:00
|
|
|
Using `inject` will cause FreeSewing to always draft the injected part prior to
|
2021-08-25 16:09:31 +02:00
|
|
|
drafting the part it gets injected to. It will, in other words, influece the draft order.
|
|
|
|
|
|
|
|
<Note>
|
|
|
|
|
|
|
|
For inheriting parts from other patterns, please refer to [Design inheritance](/howtos/code/inheritance/).
|
|
|
|
|
|
|
|
</Note>
|