Part.Dwg
Part.Dwg holds the complete 2D representation of a sheet-metal part after it has been
unfolded from its 3D model (or imported directly from a flat format such as DXF).
It is an instance of Drawing2 — a container that stores every geometric and semantic
element of the flat blank.
File: Core/Drawing/Drawing.cs — class Drawing2
The Big Picture
Drawing2
├── AList<Layer2> Layers ← named groups with display and semantic roles
├── AList<Entity2> Entities ← all geometry and annotation
│ ├── E2Pline[] ← contours (blank outline, holes, slots …)
│ ├── E2Bendline[] ← bend marks (where to fold, at what angle)
│ ├── E2Point[] ← pierce points, forming centres, approach markers
│ ├── E2Text[] ← text labels, part numbers, engrave text
│ ├── E2Insert[] ← block references (DXF blocks / sub-assemblies)
│ ├── E2Spline[] ← free-form spline curves (from DXF)
│ └── E2Dimension[] ← dimension annotations
├── List<Block2> Blocks ← reusable block definitions (referenced by E2Insert)
└── List<FormInfo> FormInfos ← 3D press-form metadata (from .geo import)
Every entity knows which Layer2 it lives on.
The layer carries both display information (colour, line type, visibility) and a semantic
role (EUse) that tells the rest of the system how to treat the entity — whether to cut
it, mark it, skip it for nesting, etc.
Drawing2 — Top-Level Properties
File: Core/Drawing/Drawing.cs
| Property | Type | Meaning |
|---|---|---|
|
|
All geometry and annotation in the drawing |
|
|
All layers; every entity belongs to one |
|
|
Reusable block definitions (referenced by E2Insert) |
|
|
Press-form metadata from imported .geo files |
|
|
Back-reference to the owning Part |
|
|
Bounding box of all non-auxiliary entities |
|
|
Net enclosed area (outer minus holes), in mm² |
|
|
Centre of gravity of the flat blank |
|
|
Whether bend-lines have been put in processing order |
|
|
Hint used to keep the base plane stable across fold operations |
Computed Shape Properties
| Property | Meaning |
|---|---|
|
The single outer boundary contour (throws if there is more than one) |
|
All outer boundary contours (for multi-body drawings) |
|
Outer contours relevant to CAM (excludes auxiliary layers) |
|
All closed |
|
All open |
|
All |
|
Width of the narrowest flange (used for tool selection) |
|
Width × height of the pline bounding box |
Layers — Layer2
File: Core/Drawing/DwgAux.cs — class Layer2
A Layer2 is a named group. Every entity in the drawing belongs to exactly one layer.
Layers serve two purposes: display (colour, line style) and semantics (what this entity
is used for).
| Property | Type | Meaning |
|---|---|---|
|
|
Layer name, e.g. |
|
|
Default display colour for entities on this layer |
|
|
Line style: |
|
|
Semantic role (see table below) |
|
|
Whether entities on this layer are shown |
|
|
Prevents accidental editing |
Layer2.EUse — Semantic Roles
| EUse | Meaning |
|---|---|
|
Normal layer — geometry here is cut by laser or punch |
|
Auxiliary / construction — ignored by CAM and nesting |
|
Mountain (upward) bend lines |
|
Valley (downward) bend lines |
|
Used for inside/outside classification only — not tooled |
|
Used for inside/outside classification only — not tooled |
|
Engrave / mark — not cut through; becomes a laser marking path |
|
User-placed point that locks where the laser enters the contour |
|
Text marker that forces a specific cutting order |
|
Centre point or small L-mark of a press-form feature |
|
Outline (footprint) of a press-form feature; moved to auxiliary during CAM |
|
Approach and exit paths generated by laser tooling; not rendered in the 2D view |
|
Path to be evaporated (very light laser pass, no kerf) |
|
Path to be dot-punched (Trumpf marking method) |
|
Informational — shown in reports but not tooled |
|
Tooling outlines created by Flux or MetaCAM |
|
Note
|
Auxiliary is a computed property that returns true for Aux, ApproachMarker,
SequenceMarker, FormCenter, and Info. Auxiliary entities are excluded from
bounding-box computation, nesting outlines, and most CAM operations.
|
The Entity Hierarchy
File: Core/Drawing/2DEntity.cs — class Entity2 (abstract base)
Every object in Drawing2.Entities inherits from Entity2.
The base class provides:
| Property / Method | Type | Meaning |
|---|---|---|
|
|
Stable numeric identity assigned when added to the drawing |
|
|
The layer this entity belongs to |
|
|
Per-entity colour override ( |
|
|
Bitfield of entity-level state (see below) |
|
|
Back-reference to the owning drawing |
|
|
Axis-aligned bounding box (abstract — each subtype computes its own) |
|
— |
Transform the entity by a |
E2Flags — Per-Entity State Bits
| Flag | Meaning |
|---|---|
|
Entity is currently selected in the editor |
|
This entity has a problem (e.g. a bend-line with non-collinear points) |
|
Structural defect: odd number of bend-line points, or degenerate geometry |
|
Bend-line was already bent by a punch press before this operation |
|
Bend-line is processed after the current bend sequence |
|
Bend-line has been assigned to a panel-bender operation |
|
Bend-line connects directly to the base plane |
|
Bend radius was set explicitly and must not be auto-adjusted |
|
This is a Z-bend with coining |
|
Contour has a chamfered (bevel) edge from a .geo import |
|
Contour is on the back face and must not receive laser tooling |
E2Pline — Contours
File: Core/Drawing/2DEntity.cs — class E2Pline
E2Pline is by far the most common entity. It wraps a Pline — a 2D polyline made of
line and arc segments.
| Property | Type | Meaning |
|---|---|---|
|
|
The underlying geometric contour |
|
|
Indexes of segments that must not be simplified during cleanup |
The Pline itself carries the geometry:
| Property | Type | Meaning |
|---|---|---|
|
|
Line and arc segments that make up the contour |
|
|
Whether the contour is a closed loop |
|
|
Outer boundary ( |
|
|
Axis-aligned bounding box |
|
|
Enclosed area (positive; holes subtract from the part area) |
How Inner and Outer Is Determined
Drawing2.PrepareForCAM() calls DoQuickMarkInOut() (or DoSlowMarkInOut() for
complex drawings). The algorithm sorts all closed plines by descending area and marks a
pline as IsOuter = true if it is not contained inside any other outer pline.
The largest closed pline that is not contained inside another closed pline becomes the
outer blank boundary. Every closed pline that lies inside the outer boundary is a hole
(IsOuter = false).
What Contours Are in the Drawing
| Contour | Origin |
|---|---|
Outer blank boundary |
Unfolded from |
Holes and cutouts |
Unfolded from inner contours of |
Open paths (slots, etch) |
Imported from DXF, or from markings on the 3D model |
Approach paths |
Added by |
E2Bendline — Bend Marks
File: Core/Drawing/2DEntity.cs — class E2Bendline
An E2Bendline marks where the part will be bent. It stores all the parameters a
press-brake or panel-bender needs to reproduce the bend from the flat blank.
| Property | Type | Meaning |
|---|---|---|
|
|
The bend-line path as pairs of points (always an even count) |
|
|
Exterior bend angle in radians (+ve = valley / up, −ve = mountain / down) |
|
|
Interior angle (π − |Angle|) — what most operators measure |
|
|
Inner bend radius in mm |
|
|
Sheet thickness (copied from |
|
|
Neutral fibre ratio (default 0.35; affects flat-width calculation) |
|
|
Width of the deformed zone in the flat blank |
|
|
Bend deduction (how much shorter the flat is vs. the unfolded length) |
|
|
Bend sequence number (1 = first bend, set after sequencing) |
|
|
Type of bend (see below) |
|
|
Name of the assigned punch tool (filled after bend tooling) |
|
|
Name of the assigned die (filled after bend tooling) |
|
|
Air gap used by the panel-bender (filled after fold tooling) |
|
|
Angle of first phase in a two-phase bend (0 = single phase) |
|
|
Number of bumps for a step-bend (> 1 = bump-bend) |
|
|
Tag name from CAD system (used by Boost / MetaCAM) |
|
|
Already bent by a punch press — skip in press-brake sequence |
|
|
Processed after the current sequence |
|
|
The matching 3D bend element (looked up by |
E2Bendline.EKind — Bend Types in the Drawing
| Kind | Meaning |
|---|---|
|
Normal air bend (most common) |
|
High-pressure coining bend |
|
Fold back with a gap |
|
Fold flat onto itself |
|
Two-phase helper bend to avoid tool collision |
|
One half of a Z-bend pair |
|
Synthesised Z-bend (two parallel |
|
One half of a double-sheet bend |
How Bend-Line Points Work
Pts always has an even number of entries. Each pair [i, i+1] is one contiguous
segment of the bend line. A bend line that is interrupted by a hole will have multiple
segments (4 or 6 points). The segments are always collinear — they all lie on the same
straight line.
// Iterate bend-line segments:
for (int i = 0; i < bendline.Pts.Length; i += 2) {
Point2 start = bendline.Pts[i];
Point2 end = bendline.Pts[i + 1];
// draw or process this segment
}
Connection Back to the 3D Model
Every E2Bendline has the same UID as the E3Flex that produced it during unfolding.
This lets the system navigate in both directions:
// From drawing → 3D model:
E3Flex flex = bendline.PairedFlex; // looks up by UID in Part.Model
// From 3D model → drawing:
E2Bendline bl = drawing.Bendlines
.FirstOrDefault(b => b.UID == flex.BendlineUID);
E2Point — Points
File: Core/Drawing/2DEntity.cs — class E2Point
A single 2D point. Its meaning depends on its layer:
| Layer use | Meaning |
|---|---|
|
Generic point (forming centre, pierce reference) |
|
User-locked laser entry point for the nearest contour |
|
Centre of a press-form feature |
|
Pierce point generated by laser tooling (a |
| Property | Type | Meaning |
|---|---|---|
|
|
The 2D coordinate |
|
|
Display mode override (cross, circle, etc.) |
|
|
Arbitrary user data attached by tooling algorithms |
E2Text — Text Labels
File: Core/Drawing/E2Text.cs — class E2Text
Text labels are stored as E2Text entities. During PrepareForCAM, text on non-auxiliary
layers is converted to E2Pline contours so it can be laser-engraved or marked.
| Property | Type | Meaning |
|---|---|---|
|
|
The text content |
|
|
Insertion point |
|
|
Character height in mm |
|
|
Vector font name |
|
|
Text rotation in radians |
|
|
Horizontal and vertical alignment |
A common use is embedding part metadata that ExplodeDrawing can read back:
// Text format understood by ExplodeDrawing:
"PN: MyPartNumber" // sets Part.Info.Name
"THICKNESS: 2.0" // sets a custom property in Part.Info.Dict
E2Insert — Block References
File: Core/Drawing/2DEntity.cs — class E2Insert
E2Insert is an instance of a reusable Block2. Blocks come from DXF imports or from
assembly drawings. An insert stores a position, rotation, and scale; the actual geometry
lives in the block definition.
| Property | Type | Meaning |
|---|---|---|
|
|
The block definition (looked up by name from |
|
|
Insertion point |
|
|
Rotation angle in radians |
|
|
Horizontal scale factor (negative = mirrored) |
|
|
Vertical scale factor |
|
|
Computed combined transform matrix |
E2Insert.Explode() replaces the insert with copies of the block’s entities transformed
into drawing space. Drawing2.ExplodeDrawing() uses this to split an assembly drawing
into individual parts.
E2Spline — Spline Curves
File: Core/Drawing/2DEntity.cs — class E2Spline
Wraps a Spline2 (B-spline or NURBS curve) imported from DXF. Splines are discretised
to line segments when needed for nesting or tooling.
| Property | Type | Meaning |
|---|---|---|
|
|
The underlying spline curve |
Block2 — Reusable Geometry Definitions
File: Core/Drawing/DwgAux.cs — class Block2
A Block2 is a named, reusable group of entities — the same concept as a DXF block or
AutoCAD block reference.
| Property | Type | Meaning |
|---|---|---|
|
|
Block name (used to look it up from |
|
|
Origin point of the block |
|
|
The geometry inside the block |
FormInfo — Press-Form Metadata
File: Core/Drawing/Drawing.cs — class FormInfo
When a part is imported from a .geo file that contains press-form features,
their 3D metadata is stored in Drawing2.FormInfos.
| Property | Type | Meaning |
|---|---|---|
|
|
3D position of the form feature on the part |
|
|
Rotation angle of the form punch |
|
|
3D mesh of the formed shape (for visualisation) |
|
|
Whether the form is applied from the underside |
|
|
Name of the punch tool that creates this form |
|
|
Name of the die |
|
|
Whether this form is applied at the same time as bending |
Internal State Flags (EFlags)
Drawing2 tracks its own preparation state with an internal EFlags bitfield.
These flags prevent redundant work when CAM algorithms call PrepareForCAM multiple
times:
| Flag | Meaning |
|---|---|
|
All closed plines have been oriented counter-clockwise |
|
|
|
Duplicate nodes and collinear segments have been removed |
|
There is exactly one outer pline (fast path for tooling) |
|
Bend-lines carry a valid |
|
Bend-lines have been updated with punch/die names from |
|
Bend-lines have been updated with air-gap from |
|
Counter-sinks identified, text converted to plines |
PrepareForCAM — Making the Drawing Ready for Tooling
Before laser tooling (or any CAM operation) reads the drawing, PrepareForCAM() is
called. It runs a sequence of normalisation steps, each guarded by a flag so it only
runs once:
PrepareForCAM()
├── DoCleanupPlines() — remove degenerate segments, collinear nodes
├── SplitCircleToArcInOpenPlines() — convert full circles in open plines to two arcs
├── DoOrientCCW() — ensure all closed plines wind counter-clockwise
├── DoQuickMarkInOut() — mark IsOuter for simple drawings (one outer pline)
│ └─ DoSlowMarkInOut() — fallback for multi-outer drawings
└── DoCAMPreprocessing()
├── Identify counter-sinks (concentric circles) → move outer to FormFootprint layer
└── Convert E2Text on cut layers → E2Pline (so they can be laser-engraved)
Complete Memory Layout
Drawing2
│
├── Layers: [Layer2, Layer2, …]
│ each: Name, Color, LineType, EUse (Std/Aux/Mark/CutTooling/…), Visible, Locked
│
├── Entities: [Entity2, Entity2, …]
│
│ ┌─ E2Pline ──────────────────────────────────────────────────────────┐
│ │ Layer → Layer2 (e.g. Std = to be cut) │
│ │ Flags → E2Flags.BevelCut, SkipLaserTooling, … │
│ │ UID → stable int used by tooling to find its cut steps │
│ │ Pline → Segment[] (lines + arcs) │
│ │ IsOuter, IsClosed, Bound, Area │
│ └────────────────────────────────────────────────────────────────────┘
│
│ ┌─ E2Bendline ───────────────────────────────────────────────────────┐
│ │ Pts[] → pairs of Point2 (each pair = one bend fragment) │
│ │ Angle → exterior bend angle (radians, ± = valley/mountain) │
│ │ Radius → inner bend radius (mm) │
│ │ Thickness → sheet thickness │
│ │ KFactor → neutral-fibre ratio (default 0.35) │
│ │ FlatWidth → developed width of bent zone │
│ │ Deduction → bend deduction │
│ │ SeqNo → processing order (1 = first) │
│ │ Kind → Std / Coining / Hem / ZBend / … │
│ │ PunchName, DieName → set by BendTech after tooling │
│ │ Airgap → set by FoldTech after tooling │
│ │ UID → same as paired E3Flex.BendlineUID in the 3D model │
│ └────────────────────────────────────────────────────────────────────┘
│
│ ┌─ E2Point ──────────────────────────────────────────────────────────┐
│ │ Pt → Point2 coordinate │
│ │ Layer → ApproachMarker / FormCenter / CutTooling / … │
│ └────────────────────────────────────────────────────────────────────┘
│
│ ┌─ E2Text ───────────────────────────────────────────────────────────┐
│ │ Text, Pt, Height, Fontname, Angle, Alignment │
│ │ Converted to E2Pline during PrepareForCAM if on a cut layer │
│ └────────────────────────────────────────────────────────────────────┘
│
│ ┌─ E2Insert ─────────────────────────────────────────────────────────┐
│ │ Block → Block2 (look up by name from Drawing2.Blocks) │
│ │ Pt, Angle, XScale, YScale → placement transform │
│ └────────────────────────────────────────────────────────────────────┘
│
│ ┌─ E2Spline ─────────────────────────────────────────────────────────┐
│ │ Spline → Spline2 (NURBS / B-spline from DXF) │
│ └────────────────────────────────────────────────────────────────────┘
│
├── Blocks: [Block2, …]
│ each: Name, Base (Point2), Entities (List<Entity2>)
│
└── FormInfos: [FormInfo, …]
each: Position, Angle, Mesh, PunchName, DieName, OnBackFace, DuringBending
Key Files
| File | Responsibility |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
Produces the drawing from a 3D model |