Direct Edit State Machine Scripts

Powerful interactive GUI tools (dimensioning, drawing, snapping) built with FCS + FCC platform integration.


Migration / Verification Status

Aspect Status / Details
Primary Sources Direct-edit-scripts.md (303 lines) + Direct-edit-script-examples.md (1,328 lines) from the HiStructOrg femcad-doc wiki. Companion content also lives in the HiStructClient mirror.
Current D-Zone State Skeleton page + first minimal registration pattern example created. No full tools ported yet.
Verified in D-Zone Not yet. The wiki examples are explicitly marked "OUTDATED (formatVersion 0.1; current supported >= 0.2)". Modernization + execution record required before any claim of "verified".
Related Verified Content 27-FCC-INPUT-ITEM-ARRAY.md, 22-FCC-PLATFORM-INTEGRATION.md, 19-CONFIGURATOR-PATTERNS.md, 05-FLI-CLI-USAGE.md
Golem / Test Coverage None specific yet. Will require new integration-style tests once examples are modernized (agent must be able to register an interactive tool using only D-Zone docs).
Migration Priority Very High — this is the single richest unique practitioner artifact in the entire wiki and has no equivalent in the numbered reference.

Last updated: 2026-05 — initial skeleton for the full-wiki migration wave.


What This Enables

Direct Edit State Machines let FCS/FCC developers create custom interactive tools that run inside the HiStruct 3D GUI:

This is the secret sauce behind many advanced configurators and productivity tools inside HiStruct.

The wiki documents:


The 8 Documented Tool Examples (to be ported)

From the source Direct-edit-script-examples.md:

  1. Draw rectangle tool — two-point rectangle with live preview (triangle-fan fill).
  2. Draw volume tool — 3D extrusion / volume creation.
  3. Dimension tool — full multi-point dimensioning with projections.
  4. Simple dimension tool — minimal working dimensioner (good first candidate for port).
  5. Dimension tool with axes projections — snaps to local axes.
  6. Polygon draw example — free-form polygon creation.
  7. Line snapping example — advanced snapping behavior.
  8. Distance measurement tool — pure measurement without permanent geometry.

Each example in the wiki includes the complete stateMachine object + the FCS-side registration (InputItemAction, validation trigger, InputItemArray storage, triggerFn that consumes userInput.parameters.*).

Plan: Port them one or two at a time into examples/direct-edit-tools/<tool-name>/ with modernized formatVersion, clean English comments, a minimal runnable FCC wrapper context, and execution notes.


Core Registration Pattern (from the wiki)

// 1. Button on the input page that launches the script
res.fit.InputItemAction {
    HtmlContent = "dimension tool",
    ValidationTrigger = "dimensionToolActionScriptDone(%userInput)",
    Behavior = "direct-edit-script:dimensionToolActionScriptDefinition",
},

// 2. The state machine definition object (usually stored as a variable or inline)
dimensionToolActionScriptDefinition := {
    id = "dimension-tool",
    formatVersion = "0.2",
    stateMachine = {
        data = { parameters = { ... } },
        states = [ ... ],
        transitions = [ ... ],
        initState = "0",
        finalStates = ["done"]
    }
}

// 3. Storage for the result + the trigger that receives the collected points
dimensionToolPoints := []

dimensionToolActionScriptDone = userInput => 
    site.construct.geometryVolumes.inputs[0].dimensionToolActionScriptTriggerFn(userInput)

dimensionToolActionScriptTriggerFn := userInput => {
    Constraints = [
        {
            Variable = "site.construct.geometryVolumes.inputs[0].dimensionToolPoints",
            Condition = False,
            Init = [
                userInput.parameters.firstPoint.values[0],
                // ... more points from userInput.parameters.*
            ],
            Explanation = "direct-edit dimension tool completed"
        }
    ]
}

The userInput object shape is derived automatically from the parameters declared in the state machine + the saveAsPointId / saveAs* names used in transitions.


Parametric Geometry Helpers (Reference)

The state machine supports a powerful expression language for points, vectors, scalars, lines, planes, and rays so you can describe "the projection of the cursor onto the ray from A in direction X" without writing custom math in FCS.

Full list (from wiki):

ParametricPoint variants: cursor, point, point-value, point-values, point-projected-to-ray, point-projected-to-line, point-projected-to-plane, point-on-line-segment, translate-point, ...

ParametricVector: vector, vector-value, parallel-vector, perpendicular-vector, camera-direction, rotate-vector, ...

ParametricScalar: scalar, scalar-value, line-length, product, ...

(Full grammar and GridAxis, ParametricLine, ParametricPlane, ParametricRay definitions live in the original wiki pages and will be transcribed here as each tool is ported.)


Verified Examples (Golem / FLI-tested)

Current status: Only the basic registration pattern below has been extracted as a starter skeleton.

See examples/direct-edit-tools/minimal-dimension-trigger/

Future entries will appear here once:


Migration Notes for Contributors

Do not claim any tool "verified in D-Zone" until the above is recorded.


Related Wiki Pages (for full context during migration)


This page was created as Wave 1 of the full femcad-doc wiki → D-Zone migration (May 2026). It follows the exact discipline established by the 26-MATERIAL-VISUALIZATION pilot: source traceability, explicit verification status, no untested claims, English-first, Golem/agent-friendly structure.

Next in this wave: Extract and modernize the "Simple dimension tool" or "Line snapping example" into a fully working, documented, minimal example folder with execution notes.