FLI - FemCAD Language Interpreter
FLI is the command-line interface for evaluating FCS scripts and expressions.
Installation & Location
FLI is often distributed extra and can be found in tools subfolder
./tools/fli.exe
or as a part of VSCode FCS pluging installation. Always search for it there first.
Otwherwise if you are on developers machine it is built as part of the FCS.Apps.Fli project:
Apps/FCS.Apps.Fli/bin/Release/net10.0/fli.exe
Build with:
dotnet build Apps/FCS.Apps.Fli/FCS.Apps.Fli.csproj -c Release
Basic Usage
Evaluate Expression (Simplest Form)
fli.exe <model.fcs> "<expression>"
Evaluates the expression in the context of the loaded model and prints the result.
Example:
fli.exe temelin3.fcs "topH + topR"
# Output: 190
Interactive Console Mode
fli.exe <model.fcs>
Opens an interactive REPL session where you can type expressions and see results.
Example:
fli.exe temelin3.fcs
# Entering interactive mode...
> topH
150
> topR
40
> topH + topR
190
Interactive Mode with Watch
fli.exe --i <model.fcs> --watch <folder>
Interactive mode with automatic file watching. When files in the watched folder change, the model reloads automatically.
Expression Evaluation
Direct Expression
fli.exe <model.fcs> "<expression>"
Examples:
# Simple variable
fli.exe model.fcs "meshSize"
# Arithmetic expression
fli.exe model.fcs "beamLength * 2"
# Property access
fli.exe model.fcs "vertex1.X"
# Method call
fli.exe model.fcs "[1,2,3].Sum"
# Complex expression
fli.exe model.fcs "Heights.Select(h => h * 1000).ToList()"
Expression with Updater (returns Proxy JSON)
fli.exe <model.fcs> "<expression>" "<updater>"
IMPORTANT: The 3-arg form returns Proxy JSON, NOT plain text. The updater overrides variable bindings before evaluation.
fli.exe model.fcs "totalCost" "{span=25,height=8}"
# Output: {"Content":1250.0,"Exception":null}
Proxy JSON structure:
{"Content": <result-value>, "Exception": null}
or on error:
{"Content": null, "Exception": "Error message here"}
The Content field is the result serialized as a JSON value (number, string, array, or object).
Evaluate Expression to Proxy JSON (named flags form)
fli.exe --evaluate-expression "<expression>" --fcs <model.fcs> [--updater "<updater>"]
Also returns Proxy JSON. Use --updater flag to pass variable overrides:
fli.exe --evaluate-expression "totalCost" --fcs model.fcs --updater "{span=25}"
# Output: {"Content":1250.0,"Exception":null}
IMPORTANT: The
--fcsflag requires an absolute path. Relative paths cause a path-doubling bug where the CWD is prepended twice. Always usePath.GetFullPath()or pass an absolute path.
Choosing Plain Text vs Proxy JSON
| Pattern | Args | Returns |
|---|---|---|
fli.exe model.fcs "expr" |
2 args | Plain text string |
fli.exe model.fcs "expr" "updater" |
3 args | Proxy JSON {"Content":...,"Exception":...} |
fli.exe --evaluate-expression "expr" --fcs model.fcs |
flags | Proxy JSON |
For Golem validation where you don't need an updater, prefer the 2-arg form for simpler output.
Output Generation
Generate HiScene JSON (primary AI validation method)
fli.exe <model.fcs> "<modelExpression>" --t 3JS --o <output.json>
Exports the complete 3D scene as structured JSON (Three.js / HiScene format). This is the recommended method for Golem to validate geometry — it provides exact vertex coordinates, face topology, and material assignments without requiring visual rendering. See 09-HISCENE-FORMAT.md for the JSON schema.
fli.exe building.fcs "Main" --t 3JS --o c:\output\scene.json
IMPORTANT: The expression for
--t 3JSmust evaluate to anIFcsImageRenderer— typically a namedGClassorGBlockinstance that wraps scene geometry. Raw imperative.fcsscripts whose top-level values are only vertex/curve/area primitives will fail. If unsure what identifier is renderable, open the model infliw.exeand check what the viewer shows, then use that identifier here.
Generate Image
fli.exe <model.fcs> "<imageExpression>" --t PNG --o <outputPath.png>
Generates an image from the model.
Image formats: PNG, JPG, SVG, DXF
fli.exe building.fcs "Model3DView" --t PNG --o c:\output\model.png
Generate Document
fli.exe <model.fcs> "<documentExpression>" --t HTML --o <outputPath.html>
Generates a structured document from report expressions.
Document formats: HTML, PDF, DOCX, XLSX, RTF, TXT
fli.exe building.fcs "CalculationReport" --t HTML --o c:\output\report.html
Generate Other Formats
# IFC (Industry Foundation Classes - BIM export)
fli.exe building.fcs "IFCModel" --t IFC --o c:\output\model.ifc
# ZIP archive
fli.exe building.fcs "PackagedOutput" --t ZIP --o c:\output\package.zip
Complete --t Format Reference
| Format | Type | Description |
|---|---|---|
3JS |
Geometry | HiScene JSON (Three.js scene) — best for AI validation |
PNG |
Image | PNG raster image |
JPG |
Image | JPEG raster image |
SVG |
Image | SVG vector graphic |
DXF |
Image | AutoCAD drawing exchange |
PDF |
Document | PDF document or image |
HTML |
Document | HTML report |
DOCX |
Document | Word document |
XLSX |
Document | Excel spreadsheet |
RTF |
Document | Rich Text Format |
TXT |
Document | Plain text |
IFC |
Model | Industry Foundation Classes |
ZIP |
Archive | ZIP archive |
ESAZIP |
Model | SCIA Engineer export (requires -template) |
Note:
BMPis NOT a supported format despite some older references. UsePNGinstead.
Generate ESA Model (SCIA Engineer Export)
fli.exe <model.fcs> --t ESAZIP -template <templatePath> --o <outputPath.zip>
Exports the structural model to SCIA Engineer format.
Example:
fli.exe building.fcs --t ESAZIP -template F2e_ModelTemplate.fcsxmlt --o c:\output\model.zip
API Functions
Execute Function
fli.exe --f <functionName>
Executes a named API function. Send request JSON via stdin:
echo '{"param1": "value1"}' | fli.exe --f calculateBeam
Execute Function with Base64 Input
fli.exe --fb64 <functionName>
Same as --f but accepts Base64-encoded JSON (preserves Unicode):
echo '<base64-json>' | fli.exe --fb64 myFunction
Execute Function with Compressed Input
fli.exe --fbz64 <functionName>
Accepts compressed (zipped) Base64-encoded JSON.
Compilation
Compile Folder
fli.exe --compile-folder <sourceDirectory> <outputDirectory>
Pre-compiles all .fcs files in a folder for faster loading.
Example:
fli.exe --compile-folder d:\projects\myModel d:\output\compiled
Compile Repository Archive
fli.exe --compile <repo.zip> <outputDirectory>
Compiles a zipped repository.
Viewer Modes
View Model in 3D
fli.exe --view-model <model.fcs>
Opens interactive 3D viewer in a browser.
Options:
fli.exe --view-model <model.fcs> --draw-settings <settings.fcsdrs> --view-settings <display.fcsdrv>
--draw-settings <file.fcsdrs>— draw/material settings file (.fcsdrsextension)--view-settings <file.fcsdrv>— projection/camera settings file (.fcsdrvextension)- Both options are optional
Example (visual validation with draw settings):
fliw.exe --view-model BuildingsComponentMain_viewAll.fcs --draw-settings BuildingsComponentMain_viewSheeting.fcsdrs
Note for Golem:
--view-modelopens an interactive browser window — it does not dump the scene to stdout or a file. Use--dump-scene(below) to get the scene data programmatically.
Dump 3D Scene to JSON (non-interactive, Golem-friendly)
fli.exe --dump-scene <model.fcs> [--draw-settings <settings.fcsdrs>] [--view-settings <display.fcsdrv>] [--evaluate-expression <expr>] [--updater <updater>] [--o <output.json>]
Generates the same 3D scene JSON that --view-model would render, but writes it to stdout (or --o <file>) without opening any window. This is the recommended non-interactive alternative to --view-model for Golem.
The model root (IAssemblyClass) is used automatically — no expression needed for typical models. Pass --evaluate-expression only if the renderable assembly is accessed via a named sub-expression.
# Dump to stdout (pipe/parse directly)
fli.exe --dump-scene building.fcs
# Dump to file
fli.exe --dump-scene building.fcs --o c:\output\scene.json
# With draw settings
fli.exe --dump-scene building.fcs --draw-settings building_draw.fcsdrs --o c:\output\scene.json
# With parameter override
fli.exe --dump-scene building.fcs --updater "{span=25,height=8}" --o c:\output\scene.json
Note: Output format is HiScene JSON. See
09-HISCENE-FORMAT.mdfor the schema.
Unlike--t 3JS, this command works on the model root directly — it does not require you to know theIFcsImageRendereridentifier.
List Model Members as JSON (Golem-friendly discovery)
fli.exe --list-members <model.fcs> [--evaluate-expression <sub-expr>] [--updater {k=v,...}] [--storage <str>]
Returns a JSON array describing all members of the model root (or a sub-expression). Each entry includes the member name, its value (eagerly evaluated), and its type. Members whose value cannot be serialised to JSON (e.g. complex FCS objects) have null value and a non-null exception field.
This is the recommended first step for Golem when exploring an unknown model: call --list-members to discover what parameters and calculated quantities are available before querying individual ones.
Output format (Members array, one object per member):
{
"Members": [
{ "Name": "topH", "Evaluated": false, "Value": 150, "Exception": null, "Type": "Int32" },
{ "Name": "topR", "Evaluated": false, "Value": 40.0, "Exception": null, "Type": "Double" },
{ "Name": "Vb1", "Evaluated": false, "Value": {}, "Exception": null, "Type": "Vertex3D" },
{ "Name": "__fm", "Evaluated": false, "Value": null, "Exception": "The method or operation is not implemented...", "Type": null }
],
"Exception": null
}
Note:
Evaluated: falsejust means the value was not in the hot cache when discovered — the value is still returned via lazy evaluation.Evaluated: truemeans it was already cached (e.g. during a prior query in the same session).
# List all root members
fli.exe --list-members building.fcs
# List members of a sub-expression
fli.exe --list-members building.fcs --evaluate-expression "floor1"
# With updater
fli.exe --list-members building.fcs --updater "{span=25,height=8}"
JSON REPL — Fast Iterative Golem Session (--i-json)
fli.exe --i-json <model.fcs> [--updater {k=v,...}] [--storage <str>]
Starts a persistent JSON REPL: the model loads once, then the process stays alive reading one JSON request line from stdin and writing one JSON response line to stdout per exchange. This eliminates startup + model-load overhead for every query — ideal for Golem iterating over many parameter combinations.
Protocol:
- Process prints
{"ready":true}when the model is loaded and ready. - Send one JSON object per line to stdin; receive one JSON object per line on stdout.
- Any line on stdout that does not start with
{(e.g. the legacy-engine warning) must be skipped.
Request types:
| Request | Response |
|---|---|
{"expr":"topH + topR"} |
{"Content":190.0,"Exception":null} |
{"expr":"topH","updater":"{topH=200}"} |
{"Content":200,"Exception":null} |
{"ls":""} |
{"Members":[...],"Exception":null} |
{"ls":"floor1"} |
members of sub-expression floor1 |
{"reload":true} |
{"reloaded":true} — clears model cache |
Per-request updater ("updater" field): applies a parameter override for that single query only, then reverts to the baseline model. The compiled package (loaded storage) is not reloaded — only the model instance is re-instantiated with the new parameter values. This makes parametric sweeps very fast.
# Start the REPL (model loads once)
fli.exe --i-json temelin3.fcs
# One-shot piped examples:
echo '{"expr":"topH + topR"}' | fli.exe --i-json temelin3.fcs
# → {"ready":true}
# → {"Content":190.0,"Exception":null}
echo '{"expr":"topH","updater":"{topH=200}"}' | fli.exe --i-json temelin3.fcs
# → {"ready":true}
# → {"Content":200,"Exception":null} ← updater applied for this query only
echo '{"ls":""}' | fli.exe --i-json temelin3.fcs
# → {"ready":true}
# → {"Members":[{"Name":"topH","Value":150,...}, ...], "Exception":null}
PowerShell multi-query example (Golem pattern for sweeping parameters):
$requests = @(
'{"expr":"topH"}',
'{"expr":"topH","updater":"{topH=200}"}',
'{"ls":""}',
'{"reload":true}',
'{"expr":"topH"}'
) -join "`n"
$requests | fli.exe --i-json temelin3.fcs | Where-Object { $_ -match '^{' }
# Filter out any non-JSON lines (e.g. legacy engine warning)
Performance note:
--i-jsonis the most efficient mode for any task requiring multiple evaluations against the same model. For a single query,fli.exe model.fcs "expr"or--evaluate-expressionare cleaner.
View Report
fli.exe --view-report <model.fcs>
Opens interactive report viewer.
Advanced Options
Trace Depth (Logging Level)
Add --td <level> to any command to control logging verbosity:
| Level | Description |
|---|---|
Error |
Only errors |
Warning |
Warnings and errors |
Info |
Informational messages (default for most commands) |
Debug |
Detailed debug information |
Trace |
Most verbose |
Example:
fli.exe model.fcs "expression" --td Debug
Profile Expressions
fli.exe --view-model model.fcs --profile-expressions-output c:\temp\profiles
Outputs performance profiling for expression evaluation.
Storage String (Remote/Custom Storage)
fli.exe --evaluate-expression "expr" --fcs model.fcs --storage "<storageString>"
Specifies storage context for cloud/remote models.
HiStruct Renderer Host
For integration with HiStruct web renderer:
fli.exe --f functionName --histruct-renderer-host http://localhost:5000
Proxy/Programming Integration
Proxy FCS (JSON Output)
fli.exe --proxy-fcs <model.fcs> "<expression>" "<updater>"
Outputs expression result as JSON proxy format.
Interactive Proxy
fli.exe --i-proxy-fcs <model.fcs> _ "<updater>"
Interactive mode with updater context.
Full Proxy Command
fli.exe --proxy <storage> <filename> "<expression>" "<updater>"
Full proxy with explicit storage specification.
Common Patterns
Testing Variable Values
# Check a simple variable
fli.exe model.fcs "variableName"
# Check array length
fli.exe model.fcs "myArray.Count"
# Check object property
fli.exe model.fcs "geometry.Area"
Batch Processing
# PowerShell: Process multiple models
Get-ChildItem *.fcs | ForEach-Object {
$result = & fli.exe $_.FullName "totalWeight"
Write-Host "$($_.Name): $result"
}
Parametric Studies
# Run with different parameter values (3-arg form returns Proxy JSON)
@(10, 15, 20, 25) | ForEach-Object {
$json = & fli.exe model.fcs "stress" "{span=$_}" | ConvertFrom-Json
$stress = $json.Content
Write-Host "Span=$_: stress=$stress"
}
# Alternative: embed override in expression to get plain text
# (works only if override is a simple reassignment in the env)
Model Validation (Syntax + Load Check)
# Check if model loads and evaluates without errors
fli.exe model.fcs "True" --td Warning
# If exit code is 0 and output is "True", model is valid
# If exit code is 1, check stderr for the error message
Golem pattern for validation:
$output = & fli.exe model.fcs "True" 2>&1
$ok = $LASTEXITCODE -eq 0
if ($ok) { Write-Host "Model OK" } else { Write-Host "Error: $output" }
Export Pipeline
# Generate multiple outputs
fli.exe building.fcs "Model3D" --t PNG --o model.png
fli.exe building.fcs "Report" --t HTML --o report.html
fli.exe building.fcs --t ESAZIP -template template.fcsxmlt --o export.zip
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error (uncaught exception during startup or argument parsing) |
IMPORTANT: Expression evaluation errors (e.g. undefined variable, type mismatch) are not reflected in the exit code. fli.exe catches them and returns a Proxy JSON with
"Exception": "error message"(3-arg /--evaluate-expressionforms) or prints the error text (2-arg form) — both with exit code 0. Always inspect the output content, not just the exit code.Error messages go to stdout, not stderr. When redirecting output, use
1>or capture stdout directly.
Environment
- Working Directory: Relative paths in .fcs files are resolved from the model's directory
- Dependencies: fli.exe requires .NET 10.0 runtime
- Output Encoding: UTF-8 (use
--fb64for guaranteed Unicode preservation) - Legacy Engine Warning: Models without a
.fcsconfig.jsonfile in their directory (or parent directories) run in emulation mode. fli.exe prints the following line to stdout before the result:
This is expected for older model files. When parsing output programmatically, strip any line starting withWarrning: No '.fcsconfig.json' found, so running legacy engine EngineVersion:'e3.emulation'!Warrning:before processing the result. Adding a.fcsconfig.jsonthat sets"EngineVersion": "e4"suppresses this warning.
FLIW - Visual Model Viewer
FLIW is an enhanced version of FLI that includes a built-in 3D model viewer using Chromium WebView and Three.js/WebGL.
Building FLIW
dotnet build Apps/FCS.Apps.Fliw/FCS.Apps.Fliw.csproj -c Release
Output: Apps/FCS.Apps.Fliw/bin/Release/net10.0/fliw.exe
Usage
# View any FCS model with 3D geometry
fliw.exe model.fcs
# All fli.exe commands also work
fliw.exe model.fcs "expression"
When to Use FLIW vs FLI
| Feature | fli.exe | fliw.exe |
|---|---|---|
| Expression evaluation | ✓ | ✓ |
| File export (PNG, PDF, etc.) | ✓ | ✓ |
| Visual 3D model viewer | ✗ | ✓ |
| Lightweight (no GUI) | ✓ | ✗ |
Visual Viewer Capabilities
- Renders any FCS model containing geometry (vertex, curve, area, volume)
- Interactive 3D navigation (rotate, pan, zoom)
- Uses Three.js/WebGL (works on any GPU)
- Window titled "HiStruct Model Viewer e4"
Comparison with FemCAD5
| Feature | FemCAD5 | fliw.exe |
|---|---|---|
| 3D Rendering | OpenGL | WebGL (Three.js) |
| GUI Framework | WPF | Chromium WebView |
| Full Editor | ✓ | ✗ |
| Lightweight | ✗ | ✓ |
| Script-only Viewing | ✗ | ✓ |
Examples Summary
# Evaluate expression
fli.exe temelin3.fcs "topH + topR"
# → 190
# Interactive mode
fli.exe temelin3.fcs
# → Opens REPL
# Generate PNG
fli.exe model.fcs "View3D" --t PNG --o output.png
# Generate HTML report
fli.exe model.fcs "Report" --t HTML --o report.html
# Export to SCIA
fli.exe model.fcs --t ESAZIP -template template.fcsxmlt --o model.zip
# Compile folder
fli.exe --compile-folder ./src ./build
# Debug mode
fli.exe model.fcs "expr" --td Debug
# Parametric evaluation
fli.exe model.fcs "result" "{param1=10,param2=20}"