Converting Weaving Drafts to WIF
Pythonconverter = DraftConverter( shafts=4, treadles=4, threading=[1, 2, 3, 4], # 1-indexed shaft per warp end, left to right tieup={1: [1, 2], 2: [2, 3], 3: [3, 4], 4: [4, 1]}, # treadle -> shafts raised treadling=[1, 2, 3, 4] # 1-indexed treadle per weft pick, top to bottom ) print(converter.to_ascii()) # drawdown preview wif_text = converter.export_wif(title="2/2 Straight Twill") open("draft.wif", "w").write(wif_text)
Progress:
- Step 1: Gather the four draft components — shaft/treadle counts, threading, tie-up, treadling
- Step 2: Validate indices (all shaft/treadle numbers must be within declared ranges, 1-indexed)
- Step 3: Instantiate
DraftConverterwith the four components - Step 4: Compute and review the drawdown via
to_ascii()to sanity-check the pattern visually - Step 5: Export to WIF 1.1 via
export_wif()and save with.wifextension - Step 6: Spot-check the WIF sections (
[TIEUP],[THREADING],[TREADLING]) against the source draft
Drawdown logic: For each pick, look up the shafts raised by that pick's treadle in the tie-up. A warp end shows as raised (1/warp float) if its threaded shaft is in that raised set, otherwise it's a weft float (0).
Rising vs. sinking shed: The converter assumes rising shed (Rising Shed=on). If source draft uses a sinking-shed (jack-less) loom convention, invert the raised-shaft logic before computing the drawdown, or set Rising Shed=off and invert bit values in the WIF output.
Example 1: 2/2 Straight Twill Input:
- threading=[1,2,3,4], tieup={1:[1,2],2:[2,3],3:[3,4],4:[4,1]}, treadling=[1,2,3,4]
Output (drawdown ASCII):
x x . .
. x x .
. . x x
x . . x
Example 2: Plain Weave (2-shaft) Input:
- shafts=2, treadles=2, threading=[1,2,1,2], tieup={1:[1],2:[2]}, treadling=[1,2,1,2]
Output (drawdown ASCII):
x . x .
. x . x
x . x .
. x . x
Example 3: Malformed tie-up reference
Input: tieup={1:[1,2]} but treadling contains treadle 3 (undefined)
Output: compute_drawdown() treats pick as raising no shafts (empty set via .get(tr, [])), producing an all-weft-float row — flag this before export, don't silently export it.
- Always print
to_ascii()and compare row/column count against expected shafts/treadles before exporting — catches indexing bugs early. - Keep threading/treadling/tie-up all 1-indexed consistently; WIF format expects 1-indexed sections.
- Preserve liftplan-only drafts (no tie-up) by treating treadling entries as direct shaft-lists rather than treadle numbers — add a
liftplan=Truemode if the source has no physical treadles. - Stamp
DateandSource Programfields accurately for archival/provenance tracking when digitizing historical drafts. - When round-tripping, re-import the exported WIF and recompute the drawdown to confirm it matches the original — cheap regression check.
- Off-by-one indexing: mixing 0-indexed Python lists with 1-indexed WIF/weaving convention causes silent shaft misalignment — always index WIF output starting at 1, even though internal arrays are 0-indexed.
- Undefined treadle/shaft references: don't let
.get(tr, [])silently default to empty; validate alltreadlingvalues exist intieupand allthreadingvalues are within1..shaftsbefore conversion. - Ignoring shed type: exporting
Rising Shed=onfor a draft documented under sinking-shed convention inverts the actual pattern — confirm shed convention with the source before export. - Skipping visual verification: never export directly to WIF without first checking the ASCII drawdown; subtle tie-up transcription errors are easy to miss in raw dict literals but obvious in the woven grid.