Creating a Pattern as an Inkscape Extension: Part 3
Continuation of Part 2
STEP 6: CREATE THE SVG OBJECTS
The formulas we’ve written calculate the x,y coordinates for each point. They don’t create the SVG elements that we see on the Inkscape canvas. If we wrap each of these formulas with a function that creates an SVG element, then we calculate the pattern point coordinates and create the SVG element in one step. The functions patternPoint(parent,id,point) and patternPointXY(parent,id,x,y) create small red circles. The parent is the pattern piece where the pattern point belongs . A is the front pattern piece, B is the back pattern piece. The SVG id should be the same as the python variable name so that there is a one-to-one mapping from the python variables to the SVG elements. It is the SVG id not the python variable name that is displayed next to each pattern point.
STEP 7: PUT THE FORMULAS INTO A PYTHON FILE
Download shirt_waist_allington_1.inx, shirt_waist_allington_1.py, and sewing_patterns.py and save to your inkscape user extension directory. For Linux, this directory is /$HOME/.config/inkscape/extensions. For Windows it’s C:\Program Files\Inkscape\extensions. For MAC it’s ~/.config/inkscape/extensions.
Open the shirt_waist_allington_1.py file. All of the measurements are converted to pixels with MEASUREMENT_CONVERSION:
All of the formulas have been pasted in the section labeled #pattern points. The formulas for curve_a3b12, b13, and a15 have been commented out. The path for the front bodice starts and ends at a11. We’re checking the point formulas, so there are no curves, only Moveto and Line commands. Here is the command that creates the path string used for the seamline and cuttingline paths for the front bodice A:
Tau Meta only uses Move ‘M’, Lineto ‘L’ and Curve ‘C’ commands. There are no relative move ‘m’, lineto ‘l’, curve ‘c’, horizontal ‘h’, vertical ‘v’, or close ‘z’ commands.
After the files are in your user inkscape directory, start Inkscape. Then select from the top menu bar Extensions/Sewing Patterns/1 Shirt Waist. A popup box with measurement fields should appear. Confirm that the measurement unit is ‘Inches’ and accept the defaults. Notice that a measurement is listed which wasn’t in the first post. The measurements needed for this pattern were listed at the top of the page in Allington’s book, here. The very first step uses a measurement that’s not in the list, and doesn’t have a listed default value. The Back Waist Length has been added with a default value that is similar to other measurements posted in the book.
Click the ‘Apply’ button on the popup box, and the extension should create the pattern.
Creating a Pattern with an Inkscape Extension will continue in the next blog post…