Metamation Developer Notes

  • Developer Notes
  • Resource Map
  • Tools
    • Code Formatting
    • Configuring Git
    • Assignments
    • Testing with Windows Sandbox
    • Single Binary Applications
    • Self-Updating Applications
  • Flux Workflow
    • Flux Workflow
    • Flux Development Style Guide
    • Release notes for Flux
    • SonarCloud analysis for Flux
    • Build a Flux SDK Program
    • Shipping Flux
    • Flux.Test
      • BasicBendAuto Test
      • LaserAuto.cs Detailed Documentation
      • Laserexample:Test1
  • Technical Notes
    • File formats
      • .FX File Format
      • Au(Gold) streams
      • .GEO File Format
      • .LST File Format
      • .LST file - technology
      • .BNC File Format
      • .WAD Files: Flux Resource Packages
      • .Curl Files: ASCII config information
    • Folders App
      • Data\Bendtools
      • Data\Machines
    • FluxCode
      • Welcome & Repo Map
      • Architecture & System Context
      • Subsystem *Bend* (Press Brake)
      • Subsystem *BCell* (Bend Cell Automation)
      • API Maps
      • Data Model Catalog
      • Design Patterns -- A Reader's Guide
      • Tests and Golden Paths
      • Guided Code Tours
      • CAM Glossary with Code Mapping
      • Assignments
      • Flux Onboarding Handbook
    • Data flow
      • Part
        • Part.Dwg
        • Part.Load
        • Part.Load to Part.Dwg
      • BendTech.cs
      • Bend Technology
      • Laser Cutting Technology
    • LTS (Long term support mechanism)
    • Machine ID Scheme
  • FluxTester
    • Commands and Scripts
    • Command Cookbook
    • Script Commands
    • BendTooling.cs Test Inventory
    • LaserTooling.cs Test Steps
    • Fluxtester Recipe Book
    • Nesting.cs Overview
    • Nesting.cs Recipe Book
    • Job.cs Overview
    • Job.cs Recipe Book
  • Software license
  • 3d party software
    • Python
  • Documentation
    • Bento documentation
      • Structure of a Bento page
      • Attributes
    • Software
      • Software Requirement
      • Installation
      • Git workflow for documentation contributors
    • Quick start guide
    • Workflow
      • Roles and responsibilities
      • Analyze
      • Edit
      • Proofread
      • Pre-Publish
      • Publish
      • Release cycle
      • Information required for Documentation Team
      • Checklist for Documenters
    • Styleguide
    • Flavoring
    • Translation
      • Ordering translation for a new document
    • Citations
    • Annotation
Technical Notes
/
Data flow
/
Bend Technology

Bend Technology

1. From Drawing2 to NC Output

This document explains how Flux turns a 2D flat drawing with bend marks into a fully tooled press-brake program. The pipeline has four distinct stages:

  1. Drawing2 — the flat part drawing, storing E2Bendline entities for every bend

  2. Model3 — the folded 3D model, storing E3Flex entities paired to those bend lines

  3. BendTech — tool assignment and sequencing, producing BendOp / BendSetup objects

  4. Output — NC code and setup-sheet report files written to disk

Entry point: Core/Part/Part.cs:327 — Part.DoBendTooling()

2. Stage 1 — The E2Bendline in Drawing2

2.1. What a bend line is

A bend line is represented by the class E2Bendline (Core/Drawing/2DEntity.cs:156). It derives from Entity2 and lives in the Drawing2 alongside the cut contour plines.

Each E2Bendline stores the complete physical description of one bend:

Property Type Meaning

Pts

Point2[]

Fragment endpoints — always an even count, each pair defines one collinear span. Points are sorted along the dominant axis at construction.

Angle

float (rad)

Exterior turn angle. +ve = valley (bend up), -ve = mountain (bend down). A hem has |Angle| = π.

InteriorAngle

double (rad)

Interior angle: (π − |Angle|) × sign(Angle)

Radius

double (mm)

Bend radius. If stored as NaN, defaults to Thickness × 1.5.

KFactor

double

Ratio of neutral-axis shift (default 0.35). Controls FlatWidth.

FlatWidth

double (mm)

Width of the deformation zone: |Angle| × (Radius + KFactor × Thickness)

Deduction

double (mm)

Bend deduction (bend allowance subtracted from flanges): 2 × (tan(|Angle|/2) × (Radius + Thickness)) − FlatWidth. For obtuse bends tan is capped at 1.

VWidth

double (mm)

V-opening width of the die (NaN if not set)

PunchName

string

Recommended punch tool name (may be null)

DieName

string

Recommended die tool name (may be null)

SeqNo

short

Bend sequence number (1-based, set during sequencing)

PrebendAngle

double (rad)

Pre-bend angle for two-phase bending (0 if none)

BumpCount

short

Number of bumping steps for step-bends

Kind

EKind

Std, Coining, DoubleSheetBendHalf, FlatBend

Airgap

float (mm)

Air gap (set only when used on a panel bender)

File: Core/Drawing/2DEntity.cs:159

public E2Bendline (IEnumerable<Point2> pts, double angle, double thickness,
                   double radius = double.NaN, double deduction = double.NaN)

2.2. Fragmented bend lines

A single logical bend line can have gaps — for example where a cutout interrupts the bend. The Pts array stores multiple contiguous fragment pairs: [A₀, B₀, A₁, B₁, …]. Each pair (Aᵢ, Bᵢ) is one span of the same bend line. All fragments are collinear; if not, the IllFormed flag is set and the bend is rejected.

2.3. E2Flags

Flag Value Meaning

Error

0x04

Bend cannot be processed

IllFormed

0x10

Odd point count or non-collinear fragments

PreBent

0x20

Already bent by punch press — skip in press-brake tech

BendOnBaseplane

0x80

Connected to the base plane (structural constraint)

PostBent

0x100

Will be bent after this tech finishes

FoldTooled

0x200

Processed on a panel bender

RadiusLocked

0x400

Radius must not be changed by tooler

ZCoining

0x800

Coining Z-bend

2.4. Layers

Bend lines are placed on dedicated layers in Drawing2:

Layer use (EUse) Meaning

VBend

Valley bend (fold up — punch presses from above)

MBend

Mountain bend (fold down — punch pushes through)

The layer use is determined from the sign of E2Bendline.Angle: positive → VBend, negative → MBend.

3. Stage 2 — The E3Flex in Model3

3.1. Pairing: E2Bendline ↔ E3Flex

When a 3D model is created from the flat drawing, each E2Bendline gets a paired E3Flex in Model3. The link is the integer UID:

File: Core/Model/E3Flex.cs

// E3Flex knows which E2Bendline it came from
public int BendlineUID { get; }

// Back-reference: finds the E2Bendline in the drawing
public E3Flex PairedBendline
    => Dwg?.Owner?.Model?.Flexes.FirstOrDefault(a => a.BendlineUID == UID);

Similarly, E2Bendline navigates back:

File: Core/Drawing/2DEntity.cs:409

public E3Flex PairedFlex
    => Dwg?.Owner?.Model?.Flexes.FirstOrDefault(a => a.BendlineUID == UID);

3.2. What E3Flex adds

E3Flex is the 3D representation of a bend: it contains the spine geometry (the actual curve along which the sheet deforms), collision geometry, windward/leeward face assignments, and phase information for multi-phase bends.

  • Spine — describes the shape of the bend zone (e.g. FlatBendSpine for hemming)

  • PhaseCount — 1 for simple bends, 2 for hems (pre-bend + flatten) or pre-bent bends

  • PhaseSplits[] — fraction of total angle completed at end of each phase

  • IsPreBent, IsPostBent — flags synchronized from the paired E2Bendline

  • IsCoining — synchronized from the paired E2Bendline

3.3. Sequence synchronization

When the user sets bend sequence numbers on E2Bendline, the drawing propagates them to the paired flexes.

File: Core/Drawing/Drawing.cs

// Changing AreBendsSequenced invalidates both technologies
Owner.BendTech = null;
Owner.FoldTech = null;

Setting BendTech = null forces a full re-tooling on the next call to DoBendTooling().

4. Stage 3 — BendTech: Tool Assignment and Sequencing

4.1. Construction

BendTech is constructed once per part per machine. Its constructor (Core/Bend/BendTech.cs:19) does the following:

  1. Collects all E3Flex objects from Model3 (reversed so they are processed outward-to-inward).

  2. Handles hem bends — splits them into two phases (pre-bend at HemPrebendAngle, then flattening).

  3. Groups simultaneous bends: flexes whose silhouettes overlap in the X-direction (parallel bends that can be done in one stroke) are gathered into a todo list via flex.CanGroupWith(flex2, pose).

  4. Also groups double-sheet bends with CanGroupDoubleSheet.

  5. Creates one BendOp per group per phase: new BendOp(this, todo, phases).

  6. Calls ops.ValidOrder() to establish the initial collision-free bend order.

  7. Detects Z-bend pairs (AnyZBendTools) and groups those into single EBendKind.ZBendAirBend or EBendKind.ZBendCoining operations.

  8. Selects a tool inventory: first tries a .btools file with the same root name as the part, then falls back to BToolLists.SelectFor(owner, machine).

File: Core/Bend/BendTech.cs:19

4.2. DoBendTooling

File: Core/Part/Part.cs:327

public EResult DoBendTooling (EDoFlags flags = EDoFlags.Default) {
    if (BendTech == null) return EResult.NeedBendTech;
    if (BendTech.IsSequenceLocked) flags |= EDoFlags.KeepSequence;
    if (flags.Has (EDoFlags.Incremental)) flags |= EDoFlags.KeepSequence;
    var res = BendTooler.Process (BendTech, flags);
    if (res.IsBad ()) { BendTech = null; return res; }
    BendTech.CodeDirty = true;
    return EResult.OK;
}

BendTooler.Process (Core/Bend/Ops/BendTooler.cs) is the core tool-assignment engine. It iterates over all BendOp objects, computes which tools physically fit each bend (based on angle, radius, part geometry), and populates the BendSetup / BendMount structures.

Key EDoFlags:

Flag Effect

Default

Full re-tooling: sequence may change, setups may be reorganized

KeepSequence

Preserve existing SeqNo order; only re-assign tools

Incremental

Implies KeepSequence; only process bends whose tools changed

DropAllTooling

Remove all existing tool assignments before re-tooling

NoGAPAdjust

Skip GAP (gripper avoidance) back-gauge adjustment

NoZBend

Do not detect or form Z-bend pairs

4.3. BendOp — one bend operation

File: API/Bend/BendOp.cs

A BendOp is one press stroke (potentially covering multiple simultaneous bends):

Property Meaning

SeqNo

Zero-based position in the bend sequence

Flexes

The E3Flex entities processed in this operation

XSpans

X-axis spans of the bend fragments (used to find which mounts engage)

XFullSpan

Bounding X-span covering all fragments

IntAngle

Interior angle in radians

Mounts

BendMount[] — upper and lower mounts that physically overlap the bend

PunchMounts

Indices into the setup’s mount list for the punch(es)

DieMounts

Indices for the die(s)

Setup

The BendSetup active during this operation

Kind

AirBend, Coining, ZBendAirBend, ZBendCoining, DoubleSheet, FlatPrebend

IsMountain

true when Angle < 0 (fold down)

IsPrebendLocked

Pre-bend angle fixed (set from a .geo file or by the user)

4.4. BendSetup and BendMount

File: API/Bend/BendSetup.cs

A BendSetup is one machine configuration — a specific arrangement of tools clamped on the press-brake beam for a group of bends. When the required tooling changes between bends, a new setup is created, and a separate NC program segment (or a separate NC file, depending on the machine) is generated for it.

Each BendSetup has a list of BendMount objects:

Property Meaning

XSpan

The X-axis interval on the machine beam this mount occupies

Tool

The BTool (punch, die, adapter, holder) in this position

IsUpper

true for punch-side mounts, false for die-side mounts

A BendOp engages a subset of mounts: those whose XSpan overlaps the bend’s XFullSpan.

4.5. Setups and NCCount

The number of distinct setups determines how many NC program files are produced. Bends that can be done without changing the tool arrangement share one setup; each tool change creates a new setup.

File: Core/Bend/BendTech.cs

/// <summary>Number of NC programs to generate (one per setup change)</summary>
public int NCCount { get; }

/// <summary>Which NC program index to generate (-1 = all setups in one file)</summary>
public int NCIndex { get; set; }

When BendMachine.OneNCForAllSetups is true, all setups are written into a single file and NCCount is treated as 1 for output purposes.

4.6. Sequence management

The bend sequence is stored as a string of operation signs (e.g. "3,1+2,4" means bend 3 first, then bends 1 and 2 simultaneously, then bend 4).

// Lock the sequence so that DoBendTooling keeps existing SeqNo order
BendTech.IsSequenceLocked = true;

// Override the sequence manually
BendTech.SetSequence("3,1,2,4");

When AreBendsSequenced is set on Drawing2, the sequence numbers from E2Bendline flow through to the paired E3Flex objects and into the BendTech constructor.

5. Stage 4 — Output Generation

5.1. Triggering output

File: Core/Bend/BendTech.cs:1106

Output is generated in BendTech.GenAllOutputs(forceGen). This is called:

  • Automatically when saving a part (if BendCodeAutogen or BendRepAutogen is enabled)

  • Manually when the user clicks the generate button

  • From ProgOutput.GenBendCode directly for batch/API use

public void GenAllOutputs (bool forceGen) {
    if ((_outputs == null || CodeDirty || forceGen) && BMachine.IsNCAllowed) {
        var bos = Settings.Outputs;
        Setups.ForEach (a => a.SortMounts ());
        StopSequencing ();

        // 1. Generate setup sheet report (HTML or PDF)
        if ((bos.BendRepAutogen || forceGen) && !bos.BendRepDestination.IsBlank ()) {
            for (int i = 0; i < NCCount; i++) {
                NCIndex = NCCount <= 1 ? -1 : i;
                _outputs.Add (ProgOutput.GenBendReport (Owner, NCIndex));
            }
        }

        // 2. Generate NC code file(s)
        if ((bos.BendCodeAutogen || forceGen) && !bos.BendCodeDestination.IsBlank ()) {
            _outputs.AddRange (ProgOutput.GenBendCode (Owner, BMachine.Id, bos.BendCodeDestination));
        }
    }
}

5.2. Setup sheet report

File: Core/Part/PartAux.cs:403

ProgOutput.GenBendReport(part, ncIndex) renders a setup sheet:

  1. Calls part.DoUnfold() to ensure the 3D model is current.

  2. Sets BendTech.NCIndex to select the right setup segment.

  3. Computes the NC code filename so the report can reference it.

  4. Loads the report template (bos.BendRepTemplate, e.g. wad:Report/trumpf.bend-bm.ftrep). Tries a language-specific variant first (trumpf.bend-bm.de.ftrep).

  5. Passes { "Part" → part } as the data source and calls Report.Render().

  6. Writes the output as HTML (default) or PDF depending on bos.BendRepFormat.

The report template has access to the entire Part object — bend ops, mounts, back-gauge positions, part dimensions, tool names — everything needed for a printable setup sheet.

5.3. NC code generation

File: Core/Part/PartAux.cs:494

ProgOutput.GenBendCode(part, mcid, outdir) writes the actual machine program:

  1. Tandem split: if the machine is a tandem press (BendMachine.IsTandem), the part is split into two halves (tech.SplitTandems()), each producing a separate program named <name>-L.<ext> / <name>-R.<ext>.

  2. Per-setup loop: iterates from 0 to NCCount-1 (or just once if OneNCForAllSetups).

  3. Filename computation (ComputeNCFileName):

    • Applies machine-specific naming rules (Trumpf DLD → prd. prefix, DLC → X prefix, program-number machines use Part.Info.ProgNo as the filename).

    • Multi-setup programs append -1, -2, etc.

    • Special post-processors (Cincinnati, ESA, Accurpress) rewrite the suffix further.

  4. Code generation: calls tech.GenerateNCCode(setupIndex) which dispatches to the machine-specific writer class.

  5. Write to disk: File.WriteAllText for text formats, File.WriteAllBytes for binary. Delem DLD additionally signs the content with DelemSign.Sign().

  6. BM5000 extra file: for BendMaster 5000 machines, writes a companion .ein file (BCellTech.EINWriter(part)).

  7. Flat DXF/GEO: optionally saves the flat pattern in the format configured in bos.BendFlatFormat.

  8. FX file: optionally saves a copy of the part as .fx (BendFXWithNC setting).

  9. Post-processor: if bos.BendCodeProcessor points to an executable, runs it with the code filename as argument.

  10. Trumpf Analytics: reports BendProcess and BendCodeGenerated events.

5.4. Post-processors and NC writers

The machine-specific code is generated by writer classes under API/Bend/Post/:

Writer class Extension Machines

BNCWriter

.bnc

Trumpf standard (Cell5K, BendMaster, TrumaBend)

BNCXWriter

.bnc

Extended BNC (BM7000, BM8000)

DLDWriter

.dld

Delem DA controllers

CybelecWriter

.nc

Cybelec controllers

BystroniWriter

.nc

Bystronic press-brakes

CincinnatiWriter

.pgm

Cincinnati press-brakes

AccupressWriter

.xml

Accurpress

EsaWriter

.prn

ESA controllers

MCBWriter

various

Komatsu MCB

A BNC program is structured as:

BD SET_METRIC C        ← metric mode
[config block]         ← machine-specific configuration
[order/part info]      ← part name, order number, quantity
[tool pieces]          ← punch and die geometry definitions
[mounts]               ← tool positions on beam
[back-gauge positions] ← gauging positions for each bend
[bend parameters]      ← angle, radius, force, material
[bend steps]           ← per-bend stroke instructions
ED                     ← end of data

5.5. Panel-bender output (FoldTech)

For panel-benders (FoldTech), the output path is separate:

File: Core/Part/PartAux.cs:689

public static ProgOutput GenFoldCode (Part part, string outdir, ...) {
    FoldCodeGenerator fcg = new (part.FoldTech);
    var xdoc = fcg.Generate ();
    // writes <partname>.xml to outdir
}

The panel-bender program is an XML file describing:

  • Blank holding positions (BlankHolding phase)

  • Blade-down and blade-up phases

  • Fold phases (from flat to final angle)

  • Back-gauge and gripper positions at each phase (BGaugePos, GripperPos)

  • Section-by-section ordering (four sides: L1, L2, R1, R2 for a fully enclosed box)

A setup-sheet report is generated by GenFoldReport using the template bos.FoldRepTemplate.

6. Complete Pipeline

Drawing2
  ├── E2Bendline (one per bend)
  │     Pts[], Angle, Radius, KFactor → FlatWidth, Deduction
  │     PunchName, DieName (hints), SeqNo, PrebendAngle
  │     Flags: PreBent, PostBent, FoldTooled, ZCoining, ...
  │     Layer: VBend (valley) or MBend (mountain)
  │
  ↓  Part.DoUnfold() / 3D modelling
  │
Model3
  ├── E3Flex (paired to E2Bendline via UID)
  │     Spine, PhaseCount, PhaseSplits
  │     IsPreBent, IsPostBent, IsCoining (synced from E2Bendline)
  │
  ↓  Part.DoBendTooling()
  │     BendTech constructor: groups simultaneous bends, detects Z-bends
  │     BendTooler.Process(): assigns tools from inventory
  │
BendTech
  ├── BendOp[] (one per press stroke)
  │     Flexes[], XSpans, IntAngle, Kind
  │     PunchMounts[], DieMounts[], Setup
  ├── BendSetup[] (one per tool-change boundary)
  │     BendMount[] (tool + X-position on beam)
  ├── NCCount  (= number of setups that require separate NC segments)
  │
  ↓  BendTech.GenAllOutputs()
  │
Output files
  ├── Setup sheet (.html or .pdf)   ← ProgOutput.GenBendReport()
  │     Template: wad:Report/*.ftrep
  │     Source: { "Part" → part }
  │
  └── NC program(s)                 ← ProgOutput.GenBendCode()
        .bnc  Trumpf BNC
        .dld  Delem DLD (signed)
        .pgm  Cincinnati
        .xml  Accurpress / panel-bender (FoldTech)
        .nc   generic
        (optional companion: .ein for BM5000, flat DXF, .fx copy)

7. Key Files

File Responsibility

Core/Drawing/2DEntity.cs:156

E2Bendline — bend mark in the flat drawing: geometry, angle, radius, deduction, flags

Core/Model/E3Flex.cs

E3Flex — 3D bend entity, paired to E2Bendline via UID

Core/Drawing/Drawing.cs

Drawing2.Bendlines — collection of all E2Bendline in the drawing; sequence synchronization

Core/Bend/BendTech.cs

BendTech — constructs BendOp[], manages sequence, drives GenAllOutputs()

Core/Bend/Ops/BendTooler.cs

BendTooler.Process() — core tool-assignment engine

API/Bend/BendOp.cs

BendOp — one press stroke (flex group + phases + tool assignments)

API/Bend/BendSetup.cs

BendSetup, BendMount — machine configuration for a group of bends

Core/Part/Part.cs:327

Part.DoBendTooling() — outer entry point, delegates to BendTooler

Core/Part/PartAux.cs:355

ProgOutput — report and NC code generation

Core/Fold/FoldTech.cs

FoldTech — panel-bender technology (parallel pipeline for non-press-brake machines)

Core/Fold/FoldStep.cs

FoldStep — individual motion phase of a fold operation

API/Bend/Post/BNCWriter.cs

Trumpf BNC post-processor

API/Bend/Post/DLDWriter.cs

Delem DLD post-processor

Contents

  • 1. From Drawing2 to NC Output
  • 2. Stage 1 — The E2Bendline in Drawing2
  • 2.1. What a bend line is
  • 2.2. Fragmented bend lines
  • 2.3. E2Flags
  • 2.4. Layers
  • 3. Stage 2 — The E3Flex in Model3
  • 3.1. Pairing: E2Bendline ↔ E3Flex
  • 3.2. What E3Flex adds
  • 3.3. Sequence synchronization
  • 4. Stage 3 — BendTech: Tool Assignment and Sequencing
  • 4.1. Construction
  • 4.2. DoBendTooling
  • 4.3. BendOp — one bend operation
  • 4.4. BendSetup and BendMount
  • 4.5. Setups and NCCount
  • 4.6. Sequence management
  • 5. Stage 4 — Output Generation
  • 5.1. Triggering output
  • 5.2. Setup sheet report
  • 5.3. NC code generation
  • 5.4. Post-processors and NC writers
  • 5.5. Panel-bender output (FoldTech)
  • 6. Complete Pipeline
  • 7. Key Files
BendTech.cs Laser Cutting Technology

      Copyright © 2025 TRUMPF Metamation. All rights reserved.

    Compiled by Bento