Skip to content

Command line interface

PyExtrusion includes a CLI for engineers, scripts and AI/tool integrations.

PyExtrusion 0.19.0 accepts canonical trim through the same input JSON used by calculate, plan, comparisons and sequences. With calculate, use --field process.trim_total_per_billet_m or --field production.final_saw_events for the new traces. Planning and sequence commands return their own result structures; these selectors are not universal flags for every command. Commercial cuts are not physical final-saw events. Legacy inputs retain their original per-pull interpretation for p=2; migrate explicitly with the Python helper.

Identity and version

pyextrusion --version
pyextrusion info

Validate JSON

pyextrusion validate press.json
pyextrusion validate case.json
pyextrusion validate annual_demand.json
pyextrusion validate planning_case.json --kind planning
pyextrusion validate production_sequence.json --kind sequence

Validation errors include their documented PX code, for example:

ERROR   PX1003 production.exit_speed_m_min: must be between 1 and 100 m/min

Official result-field glossary

pyextrusion fields
pyextrusion fields --section scrap
pyextrusion field production.bars_manufactured
pyextrusion field scrap.total_kg --format json

Field names are exact API identifiers. Use the glossary instead of guessing synonyms.

Error catalog

pyextrusion errors
pyextrusion error PX1004
pyextrusion error PX1004 --format json

Inspect a press

pyextrusion press show press.json

Calculate

pyextrusion calculate case.json --press press.json

Complete JSON:

pyextrusion calculate case.json --press press.json --format json --pretty

One raw scalar value (Python numeric precision is preserved):

pyextrusion calculate case.json --press press.json --field scrap.total_kg

One section:

pyextrusion calculate case.json --press press.json --section scrap --format json --pretty

Several exact fields:

pyextrusion calculate case.json --press press.json \
  --fields scrap.total_kg productivity.real_net_kg_h billet.length_mm \
  --format json --pretty

Inspect trim and physical events

pyextrusion calculate case.json --press press.json --fields process.trim_total_per_billet_m process.trim_per_pull_m production.final_saw_events production.internal_billet_transitions production.puller_saw_events production.billet_saw_events --format json --pretty
pyextrusion field production.final_saw_events

Input trim is set in the JSON, not by an invented --trim flag. Migration uses the Python helper; there is no implicit CLI rename of legacy fields.

Operational production planning

pyextrusion plan planning_case.json --press press.json --bars 300
pyextrusion plan planning_case.json --press press.json --billets 20
pyextrusion plan planning_case.json --press press.json --hours 2

Other supported targets:

pyextrusion plan planning_case.json --press press.json --kg 2500
pyextrusion plan planning_case.json --press press.json --metres 1800
pyextrusion plan planning_case.json --press press.json --minutes 90

Planning works with complete billets and uses only extrusion time plus the technical dead time currently modeled by PyExtrusion. StudyCase JSON remains accepted by the plan command as a compatibility bridge; planning emits a deprecation warning and PlanningCase JSON is preferred.

Production sequences

pyextrusion sequence production_sequence.json
pyextrusion sequence production_sequence.json --format json --pretty

The command preserves the list order exactly and chains only the technical press time calculated for each order. No setup, die-change, waiting or calendar time is inserted.

Compare presses

Legacy study/cotization comparison:

pyextrusion compare case.json press_a.json press_b.json press_c.json

Quantity-free process comparison:

pyextrusion compare-process planning_case.json press_a.json press_b.json press_c.json

Operational planning comparison:

pyextrusion compare-planning planning_case.json press_a.json press_b.json --bars 300
pyextrusion compare-planning planning_case.json press_a.json press_b.json --hours 2

Exact same production sequence on several presses:

pyextrusion compare-sequence production_sequence.json press_a.json press_b.json press_c.json

The new comparison commands require at least two presses and never rank them or select an automatic winner.

Annual demand

pyextrusion annual case.json --press press.json --demand annual_demand.json

or:

pyextrusion annual case.json --press press.json --value 20000 --unit kg

Recalculate with a 10% demand supplement

pyextrusion calculate case.json --press press.json --supplement-10-pct
pyextrusion annual case.json --press press.json --value 10000 --unit kg --supplement-10-pct

Disable a supplement stored in the case for one run with --no-supplement-10-pct.

Strict CLI validation

The CLI uses the same public validation rules as the Python/JSON API. Invalid units are not guessed: a JSON value cut_length_mm: 7 is rejected rather than treated as 7000 mm. NaN/Infinity, fractional exits/bars/billets, and numeric strings inside JSON are rejected with controlled PX errors.

For annual demand, --unit bars requires a whole integer value, for example --value 300 --unit bars.