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:
-
Drawing2 — the flat part drawing, storing
E2Bendlineentities for every bend -
Model3 — the folded 3D model, storing
E3Flexentities paired to those bend lines -
BendTech — tool assignment and sequencing, producing
BendOp/BendSetupobjects -
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 |
|---|---|---|
|
|
Fragment endpoints — always an even count, each pair defines one collinear span. Points are sorted along the dominant axis at construction. |
|
|
Exterior turn angle. +ve = valley (bend up), -ve = mountain (bend down). A hem has |
|
|
Interior angle: |
|
|
Bend radius. If stored as NaN, defaults to |
|
|
Ratio of neutral-axis shift (default 0.35). Controls |
|
|
Width of the deformation zone: |
|
|
Bend deduction (bend allowance subtracted from flanges): |
|
|
V-opening width of the die (NaN if not set) |
|
|
Recommended punch tool name (may be null) |
|
|
Recommended die tool name (may be null) |
|
|
Bend sequence number (1-based, set during sequencing) |
|
|
Pre-bend angle for two-phase bending (0 if none) |
|
|
Number of bumping steps for step-bends |
|
|
|
|
|
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 |
|---|---|---|
|
0x04 |
Bend cannot be processed |
|
0x10 |
Odd point count or non-collinear fragments |
|
0x20 |
Already bent by punch press — skip in press-brake tech |
|
0x80 |
Connected to the base plane (structural constraint) |
|
0x100 |
Will be bent after this tech finishes |
|
0x200 |
Processed on a panel bender |
|
0x400 |
Radius must not be changed by tooler |
|
0x800 |
Coining Z-bend |
2.4. Layers
Bend lines are placed on dedicated layers in Drawing2:
Layer use (EUse) |
Meaning |
|---|---|
|
Valley bend (fold up — punch presses from above) |
|
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.FlatBendSpinefor 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 pairedE2Bendline -
IsCoining— synchronized from the pairedE2Bendline
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:
-
Collects all
E3Flexobjects fromModel3(reversed so they are processed outward-to-inward). -
Handles hem bends — splits them into two phases (pre-bend at
HemPrebendAngle, then flattening). -
Groups simultaneous bends: flexes whose silhouettes overlap in the X-direction (parallel bends that can be done in one stroke) are gathered into a
todolist viaflex.CanGroupWith(flex2, pose). -
Also groups double-sheet bends with
CanGroupDoubleSheet. -
Creates one
BendOpper group per phase:new BendOp(this, todo, phases). -
Calls
ops.ValidOrder()to establish the initial collision-free bend order. -
Detects Z-bend pairs (
AnyZBendTools) and groups those into singleEBendKind.ZBendAirBendorEBendKind.ZBendCoiningoperations. -
Selects a tool inventory: first tries a
.btoolsfile with the same root name as the part, then falls back toBToolLists.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 |
|---|---|
|
Full re-tooling: sequence may change, setups may be reorganized |
|
Preserve existing |
|
Implies |
|
Remove all existing tool assignments before re-tooling |
|
Skip GAP (gripper avoidance) back-gauge adjustment |
|
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 |
|---|---|
|
Zero-based position in the bend sequence |
|
The |
|
X-axis spans of the bend fragments (used to find which mounts engage) |
|
Bounding X-span covering all fragments |
|
Interior angle in radians |
|
|
|
Indices into the setup’s mount list for the punch(es) |
|
Indices for the die(s) |
|
The |
|
|
|
|
|
Pre-bend angle fixed (set from a |
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 |
|---|---|
|
The X-axis interval on the machine beam this mount occupies |
|
The |
|
|
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
BendCodeAutogenorBendRepAutogenis enabled) -
Manually when the user clicks the generate button
-
From
ProgOutput.GenBendCodedirectly 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:
-
Calls
part.DoUnfold()to ensure the 3D model is current. -
Sets
BendTech.NCIndexto select the right setup segment. -
Computes the NC code filename so the report can reference it.
-
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). -
Passes
{ "Part" → part }as the data source and callsReport.Render(). -
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:
-
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>. -
Per-setup loop: iterates from
0toNCCount-1(or just once ifOneNCForAllSetups). -
Filename computation (
ComputeNCFileName):-
Applies machine-specific naming rules (Trumpf DLD →
prd.prefix, DLC →Xprefix, program-number machines usePart.Info.ProgNoas the filename). -
Multi-setup programs append
-1,-2, etc. -
Special post-processors (Cincinnati, ESA, Accurpress) rewrite the suffix further.
-
-
Code generation: calls
tech.GenerateNCCode(setupIndex)which dispatches to the machine-specific writer class. -
Write to disk:
File.WriteAllTextfor text formats,File.WriteAllBytesfor binary. Delem DLD additionally signs the content withDelemSign.Sign(). -
BM5000 extra file: for BendMaster 5000 machines, writes a companion
.einfile (BCellTech.EINWriter(part)). -
Flat DXF/GEO: optionally saves the flat pattern in the format configured in
bos.BendFlatFormat. -
FX file: optionally saves a copy of the part as
.fx(BendFXWithNCsetting). -
Post-processor: if
bos.BendCodeProcessorpoints to an executable, runs it with the code filename as argument. -
Trumpf Analytics: reports
BendProcessandBendCodeGeneratedevents.
5.4. Post-processors and NC writers
The machine-specific code is generated by writer classes under API/Bend/Post/:
| Writer class | Extension | Machines |
|---|---|---|
|
|
Trumpf standard (Cell5K, BendMaster, TrumaBend) |
|
|
Extended BNC (BM7000, BM8000) |
|
|
Delem DA controllers |
|
|
Cybelec controllers |
|
|
Bystronic press-brakes |
|
|
Cincinnati press-brakes |
|
|
Accurpress |
|
|
ESA controllers |
|
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 (
BlankHoldingphase) -
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 |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Trumpf BNC post-processor |
|
Delem DLD post-processor |