Skip to main content

For Developers

A map for automating with scripts or changing the add-on. The source is GPL-3.0-or-later (some parts, such as solver/newton_patch/, are Apache-2.0; see each folder's LICENSE).

Three layers​

LayerWhereUses Blender (bpy)What it does
Pattern logiccore/noreads and edits the pattern data (a JSON dict): drafting, seams, fabrics, sewing order. Testable without Blender
Blender sidethe .py files at the topyesmakes the objects; tools, panels, overlays, selection
Cloth simulationsolver/noruns in a separate process, moves the cloth with NVIDIA Newton, returns the result as files

Main modules​

ModuleWhat it holds
store.pythe one way in and out of the pattern data (text AC9_ClothSim_Spec_<garment>)
core/spec.pythe pattern data's layout and the functions that edit it; the table of piece state names STATE_NAMES
core/draft.pydrafting edits (move corners and edges, draw a piece, mirrored copy), keeping the seams valid
pattern_view.pymakes the flat pattern objects
placed_view.pymakes the placed objects: pairs' mirroring, origins, reading a piece moved by hand
dress.pydressing: meshes the pieces, starts the simulation process, brings the result back to the garment
selection.pyreads and writes the piece selection (Selection and the Gizmo)
piece_move.pyhandles on the dressed garment's pieces
toolbar.py, draft_tool.pythe tools in the left toolbar
i18n_ja.pythe Japanese interface

Rules the code keeps​

  • The pattern data is the truth. Do not change flat pattern objects directly: edit the pattern data with the functions in core/, then write it back with store.py. The objects are made again.
  • Placed objects may be moved directly. The simulation starts from the adjusted shapes on screen at the time.
  • Selection is written through selection.py. Calling select_set elsewhere puts the 2D and 3D marks out of step. The places that write it directly, for a reason, are listed with the reason in tests/test_selection_writers.py.
  • A name shown on screen is read from one table. The same string is not written twice (for example, piece states come from STATE_NAMES in core/spec.py). Renaming one changes its tests and the manual in the same change.
  • Names kept in a .blend (object names, property names, JSON keys): when changing one, make sure older files still open.

Tests​

The tests in tests/ run Blender in the background:

blender -b --factory-startup --python tests/test_<name>.py -- <folder holding ac9_cloth_sim>

The manual for AI assistants​

LLM/ holds the manual an AI assistant reads. LLM/README.md is made from part of this manual (the Japanese one), so do not edit it; edit docs/ja/ instead.