Using API via command line

MatrixFrame comes with console programs that calculate without the user interface. Use them from a script or from your own software: each run reads its input from files and writes its results and reports to files.

ProgramUse
MxFrameAPI.exeCalculates a MatrixFrame project and writes its results and reports.
MxToolsAPI.exeCalculates MatrixTools documents and writes MatrixTools reports.
MxFloorAPI.exeCalculates MatrixFloor projects; see MxFloor API.

The programs are in the Bin folder of MatrixFrame. With a standard installation of MatrixFrame 2027 this is:

C:\Program Files\Matrix\MatrixFrame 2027\Bin

A program that is started without parameters lists its switches. The licence has to include the API module.

A path or a list that contains a space or a | sign has to be written between double quotes.

Versions

The examples on this page were made with MatrixFrame 2027. Most of it also works in earlier versions; the table shows since when. Earlier versions are installed in C:\Program Files (x86)\Matrix\MatrixFrame [version]\Bin.

ProgramFunctionAvailable
MxFrameAPI.exe/LOAD, /LG, /CALC, /RESULT, /REPORT, /SAVE, /SETTINGSsince 5.6
MxFrameAPI.exe/REPORTLISTsince 6.0
MxFrameAPI.exe/CONCRETE, /STEEL, /TIMBER5.6 to 2026
MxFrameAPI.exeResult flags concrete, steel, timbersince 2027
MxToolsAPI.exeInput file with header and data, /OUTPUT:CONSOLEsince 6.1
MxToolsAPI.exe/LOAD with /SAVEsince 6.0
MxToolsAPI.exe/LOAD with /REPORTsince 2027

MxFrame API

SwitchDescription
/LOAD:"<path>"Loads a MatrixFrame project.
/LGRuns the load generator after the project is loaded.
/CALCRuns the structural analysis.
/CALC:advancedRuns the advanced structural analysis.
/RESULT:"<flags>"Writes the results of the analysis to <project>.results.xml. The flags, separated by |, select what is written; see below.
/REPORT:"<items>"Writes a report with the given items, separated by |, to <project>.report.pdf.
/REPORTLISTLists the report items.
/SAVE:"<path>"Saves the project.
/SETTINGS:"<path>"Settings to use instead of those of MatrixFrame: a file, or the settings text itself.

Examples

"C:\Program Files\Matrix\MatrixFrame 2027\Bin\MxFrameAPI.exe" /LOAD:"C:\Projects\simple-project.mxml" /CALC /RESULT:all /REPORT:"structure-geometry|result-forces"

"C:\Program Files\Matrix\MatrixFrame 2027\Bin\MxFrameAPI.exe" /LOAD:"C:\Projects\steel-project.mxml" /CALC /RESULT:"member-forces|steel"

"C:\Program Files\Matrix\MatrixFrame 2027\Bin\MxFrameAPI.exe" /LOAD:"C:\Projects\concrete-project.mxml" /CALC /RESULT:"member-forces|concrete"

"C:\Program Files\Matrix\MatrixFrame 2027\Bin\MxFrameAPI.exe" /LOAD:"C:\Projects\timber-project.mxml" /CALC /RESULT:"member-forces|timber|json"

The files are written next to the project: simple-project.results.xml and simple-project.report.pdf for the first example.

Result flags

/RESULT without flags writes nodal-forces|member-forces|nodal-displacements|member-deflections|support-reactions|envelopes.

FlagWrites
nodal-forcesNodal forces
member-forcesMember forces
nodal-displacementsNodal displacements
member-deflectionsMember deflections
support-reactionsSupport reactions
force-cutsForces in the member cuts
displ-cutsDisplacements in the member cuts
envelopesEnvelopes
polynomsPolynomials
stressesStresses
concreteConcrete code check (in the XML file only)
steelSteel code check
timberTimber code check
allEverything; can be combined with json
jsonWrites <project>.results.json instead of XML

The flags are described in more detail on Results output flags. The code check data, which the versions up to 2026 write with the switches /CONCRETE, /STEEL and /TIMBER, is asked for with the result flags concrete, steel and timber since 2027.

Report items

/REPORTLIST prints the items of the installed version:

ItemChapter
structure-infoStructure info
structure-geometryGeometry
structure-sectionsSections
restraintsRestraints
structure-fnlconcreteFNL concrete
loadsLoads
result-analysisAnalysis
result-envelopesEnvelope
result-forcesForces
result-reactionsSupport reactions
result-displacementsNodal displacements
result-deflectionsDeflections
result-soilpressureSoil pressure
result-stressesStresses
result-fnlFNL results
result-dynamicDynamic analysis results
result-stabilityF-euler analysis results
cc-steelSteel code check
cc-jc-steelSteel joint connections
cc-timberTimber code check
cc-telecomTelecom
cc-concreteConcrete code check
toolsTools

MxTools API

MxToolsAPI.exe does two things:

  • it calculates documents from input files and writes each answer as JSON;
  • it writes the reports of a MatrixTools project that was made in MatrixTools.
SwitchDescription
/DATA:"<path>"Calculates one input file (JSON or YAML) and writes the answer.
/LOAD:"<path>"Loads a MatrixTools project (*.mxft or *.mxtml).
/REPORTWith /LOAD: writes the report of every document of the project to <project>.<document id>.report.pdf.
/SAVE:"<path>"With /LOAD: saves the loaded project, as *.mxft or *.mxtml.
/OUTPUT:CONSOLEPrints the answer instead of writing it to a file.
/SETTINGS:"<path>"Design code and language to use instead of those of MatrixTools: a file, or the settings text itself.

Calculate documents from input files

/DATA calculates one input file:

"C:\Program Files\Matrix\MatrixFrame 2027\Bin\MxToolsAPI.exe" /DATA:"C:\Projects\mxtools.steel.cross.input.json"

This writes the answer to mxtools.steel.cross.input.results.json next to the input file; the answer of a YAML input file gets the extension of that file. With /OUTPUT:CONSOLE the answer is printed instead.

Since 2027 the program ends with exit code 0 when the run succeeded and with exit code 1 when it failed, for example when the input file is not found or cannot be calculated.

The input file: JSON or YAML

An input file is written in JSON or in YAML. Both hold the same data, so use the one that suits you: JSON is the easiest to write from software, YAML is easier to read and to type and it can hold comments. The file has two parts:

  • header with tid, the document type (see the table below);
  • data with doc, the input of the document.

Forces are in N, moments in Nm and lengths in m.

YAML

# one of (SERIES SECTION) or both must be provided.
# if SECTION is found then always single section will be calculated.
# otherwise all sections in series will be calculated.
header:
  tid: 3000
data:
  doc:
    series: CLS
    section: CLS 38 x 64
    material: C30 # required
    serviceClass: 1 # required. Valid values: 1, 2, 3
    loadingClass: long # required. Timber.yml -> loadingClass
    Mx: 500 # Nm, optional
    My: 5000 # Nm, optional
    Mz: 1000 # Nm, optional
    Nx: -10000 # N, optional
    Vy: 5000 # N, optional
    Vz: 12000 # N, optional

JSON

{
  "header": {
    "tid": 3000
  },
  "data": {
    "doc": {
      "series": "CLS",
      "section": "CLS 38 x 64",
      "material": "C30",
      "serviceClass": 1,
      "loadingClass": "long",
      "Mx": 500,
      "My": 5000,
      "Mz": 1000,
      "Nx": -10000,
      "Vy": 5000,
      "Vz": 12000
    }
  }
}

The comments in the YAML examples tell for every value whether it is required and what it may be. Where a comment names a list, such as Timber.yml -> loadingClass, that list is in the folder %ProgramData%\Matrix\MatrixFrame\2027\Interoperability\Library. The same samples are installed in %ProgramData%\Matrix\MatrixFrame\2027\Interoperability\Samples\MatrixTools.

The answer

The answer is always JSON, in UTF-8. output holds the results of the document, time the calculation time in seconds:

{
  "output": [
    {
      "section": "CLS 38 x 64",
      "reference": "NEN-EN1995-1-1 (6.19)",
      "uc": 12.328179839268198,
      "checkOk": false
    }
  ],
  "version": "1.0",
  "time": 0.0005559
}

When the input cannot be calculated the answer has no output; it has an error instead:

{
  "version": "1.0",
  "error": {
    "id": 1004,
    "message": "wrong input data"
  },
  "time": 0.0005
}
IdMessageMeaning
1001failed to parse jsonThe input file is neither valid JSON nor valid YAML.
1002header branch not foundThe input has no header. Input files of earlier versions, without header and data, give this answer.
1003data branch not foundThe input has no data.
1004wrong input dataA value in data.doc is missing or not known, for example a section or a material name.
4000no implementation for this document typeThe document type cannot be calculated from an input file.
4001no document type in headerThe header has no tid.

Which values can I use?

For a document type that chooses from lists, an input with aid: data instead of doc answers with those lists, for example the series, sections and materials of a steel cross-section:

header:
  tid: 2000
data:
  aid: data

Design code and language

A calculation uses the design code and the language that MatrixTools was last used with on the computer. The texts in an answer, such as warnings, are in that language. /SETTINGS sets both, and MatrixTools keeps them afterwards:

# MatrixTools API settings - pass with /SETTINGS:"mxtools.settings.yaml"
# Without it the console uses the design code and the language MatrixTools was last used with.
settings:
  codes: NEN-EN   # EN, NEN-EN, NBN-EN, DIN-EN, LST-EN, SS-EN, DS-EN; second generation: 2G-EN, 2G-NEN, 2G-NBN, 2G-DIN, ...
  language: US    # language of the texts in an answer: US, NL, DE, LT

Document types and examples

These document types can be calculated from an input file. Every example is available as YAML and as JSON, with the answer it gives. All of them in one file: mxtoolsapi-examples.zip.

DocumentType

Input

Answer
Concrete cross-section M+V+T1001YAMLJSONJSON
Concrete cross-section, bending resistance MRd1002YAMLJSONJSON
Concrete cross-section, shear resistance VRd1003YAMLJSONJSON
Concrete column + fire1004YAMLJSONJSON
Concrete punching1005YAMLJSONJSON
Concrete punching, advanced1006YAMLJSONJSON
Concrete M-N-Kappa diagram1010YAMLJSONJSON
Concrete juncture1013YAMLJSONJSON
Steel cross-section2000YAMLJSONJSON
Steel cross-section: the series, sections and materials to choose from2000YAMLJSONJSON
Steel section library2004YAMLJSONJSON
Steel fire protection2006YAMLJSONJSON
Timber cross-section3000YAMLJSONJSON
Timber cross-section: the series, sections and materials to choose from3000YAMLJSONJSON
Strut and tie: deep beam8000YAMLJSONJSON
Strut and tie: foundation block8001YAMLJSONJSON
Strut and tie: corbel8002YAMLJSONJSON
Strut and tie: T-shape8003YAMLJSONJSON
Strut and tie: half joint8004YAMLJSONJSON
Strut and tie: beam with a hole8005YAMLJSONJSON
Strut and tie: column8006YAMLJSONJSON

The examples were calculated with the design code NEN-EN; see mxtools.settings.yaml.

Other document types, for example a timber beam floor, cannot be calculated from an input file. A report is always written from a project file; see the next section.

Write the reports of a MatrixTools project

Every document of a project made in MatrixTools can be written as a report, also the document types that cannot be calculated from an input file, such as the timber beam floors and roofs, the steel and timber columns, masonry and the steel joint connections.

"C:\Program Files\Matrix\MatrixFrame 2027\Bin\MxToolsAPI.exe" /LOAD:"C:\Projects\floor.mxtml" /REPORT

The program writes one PDF for each document of the project:

loading project: C:\Projects\floor.mxtml
report generated to: C:\Projects\floor.1.report.pdf
  • The project is a *.mxft or a *.mxtml file, as saved by MatrixTools.
  • A report is named <project>.<document id>.report.pdf and is written next to the project. An existing file is replaced.
  • The document id is the id the document has in the project; 0 is a valid id.
  • The report is the one that Document print preview shows in MatrixTools: the document is calculated and reported with the report contents chosen in MatrixTools for its document type.

Example: mxtools.project.timber-floor.mxtml, a timber beam floor (document type 3002), gives mxtools.project.timber-floor.1.report.pdf.

The same from your own program

The functions of the console are also available to .NET and COM programs; see API via COM. There CallData takes the text of an input file and returns the answer, and LoadProject followed by MakeReport writes the report of a document of a project.