← API Guide / Getting started

Getting started

Install SCPC, write a small Plate, export native commands and run them.

Why SCPC exists

SCPC (SolidCraft Python Commands) creates the exact native {"commands":[{"command":"…","params":{…}}]} data structure accepted by SolidCraft. You write ordinary Python for loops, variables and reuse, but every script.add() names a real SolidCraft operation. There is no separate geometry language.

SCPF (Forge) provides higher-level modelling objects, while SCPC exposes native commands directly. Both can create editable SolidCraft designs, but they are deliberately independent.

Install on your machine

From the root of lib.py.solidcraft.cmd, activate your normal Python environment and install the library in editable mode:

conda activate brainboxemb-dev-tools
python -m pip install -e .
python -m unittest discover -s tests -p "test_*.py" -v

Write your first script

Save the following as model.py. A Python source file defines one non-empty Script; it does not require a main() function or show().

from scpc import Script

script = Script()
script.add("sketch.create", plane="XY", name="Base")
script.add("sketch.rectangle.two_point", p0=[0, 0], p1=[100, 60])
script.add("sketch.finish")
script.add("solid.extrude", distance="10 mm", body_name="Plate")

The real Plate example also defines parameters, rounds its vertical edges and adds four holes; that example is part of the native CI tests.

Export, inspect and execute

python -m scpc model.py --out output/plate.json
python -m scpc model.py --run --save output/plate.sc

--out only exports JSON. --run uses the installed solidcraft-cli and can save an editable .sc design. You can run the JSON file later, without re-running the Python source:

python -m scpc output/plate.json --run --save output/replayed.sc
Two separate checks. Python accepting a command and SolidCraft accepting the command are not the same as proving the finished geometry is correct. See Verification and testing.