| name | acad-dimensions |
| description | Dimensions — aligned, rotated, arc, radial, angular, ordinate, text overrides |
AutoCAD Dimensions
Use this skill when creating or modifying dimension objects - linear, aligned, angular, radial, diametric, arc, and ordinate dimensions, plus dimension styles.
Dimension Class Hierarchy
Dimension (abstract base)
├── AlignedDimension
├── RotatedDimension
├── ArcDimension
├── DiametricDimension
├── RadialDimension
├── LineAngularDimension2
├── Point3AngularDimension
└── OrdinateDimension
Creating Dimensions
Aligned Dimension
AlignedDimension dim = new AlignedDimension(
new Point3d(0, 0, 0),
new Point3d(100, 0, 0),
new Point3d(50, 20, 0),
"",
db.Dimstyle);
btr.AppendEntity(dim);
tr.AddNewlyCreatedDBObject(dim, true);
Rotated Dimension
RotatedDimension dim = new RotatedDimension(
0.0,
new Point3d(0, 0, 0),
new Point3d(100, 50, 0),
new Point3d(50, 70, 0),
"",
db.Dimstyle);
Arc Dimension
ArcDimension dim = new ArcDimension(
new Point3d(50, 50, 0),
new Point3d(100, 50, 0),
new Point3d(50, 100, 0),
new Point3d(80, 80, 0),
"",
db.Dimstyle);
Radial Dimension
RadialDimension dim = new RadialDimension(
new Point3d(50, 50, 0),
new Point3d(100, 50, 0),
10.0,
"",
db.Dimstyle);
Diametric Dimension
DiametricDimension dim = new DiametricDimension(
new Point3d(100, 50, 0),
new Point3d(0, 50, 0),
10.0,
"",
db.Dimstyle);
Angular Dimension (2-Line)
LineAngularDimension2 dim = new LineAngularDimension2(
new Point3d(0, 0, 0),
new Point3d(100, 0, 0),
new Point3d(0, 0, 0),
new Point3d(0, 100, 0),
new Point3d(30, 30, 0),
"",
db.Dimstyle);
Angular Dimension (3-Point)
Point3AngularDimension dim = new Point3AngularDimension(
new Point3d(50, 50, 0),
new Point3d(100, 50, 0),
new Point3d(50, 100, 0),
new Point3d(80, 80, 0),
"",
db.Dimstyle);
Ordinate Dimension
OrdinateDimension dim = new OrdinateDimension(
true,
new Point3d(100, 50, 0),
new Point3d(100, 80, 0),
"",
db.Dimstyle);
Dimension Styles
DimStyleTable dst = (DimStyleTable)tr.GetObject(
db.DimStyleTableId, OpenMode.ForWrite);
DimStyleTableRecord dstr = new DimStyleTableRecord();
dstr.Name = "MyDimStyle";
dstr.Dimtxt = 2.5;
dstr.Dimtxsty = textStyleId;
dstr.Dimgap = 1.0;
dstr.Dimtad = 1;
dstr.Dimasz = 2.5;
dstr.Dimtsz = 0.0;
dstr.Dimexe = 1.25;
dstr.Dimexo = 0.625;
dstr.Dimscale = 1.0;
dstr.Dimdec = 2;
dstr.Dimlunit = 2;
ObjectId styleId = dst.Add(dstr);
tr.AddNewlyCreatedDBObject(dstr, true);
dim.DimensionStyle = styleId;
Gotchas
- Empty string
"" for DimensionText shows the measured value; use "<>" to embed the measurement within custom text (e.g., "Length: <> mm")
- All Dim* properties on a Dimension entity are per-entity overrides - they only take effect when they differ from the dimension style
- Use
SetDimstyleData() to apply all dim variable overrides from a style at once; individual property sets only override specific variables
Measurement is read-only and computed from geometry points - move the points to change the measurement
RecomputeDimensionBlock(true) must be called after changing geometry points programmatically for the visual to update
- Angular dimensions measure the angle on the side where
ArcPoint is placed - the arc point determines which of the four possible angles is measured
DimStyleTableRecord.Dimtxsty is the text style; Dimension.TextStyleId is the same thing but with a friendlier name
Dimblk sets both arrows; use Dimblk1/Dimblk2 with Dimsah = true for separate arrow heads
- Ordinate dimensions:
UsingXAxis = true measures X coordinates, UsingXAxis = false measures Y coordinates
GetDimstyleData() returns a temporary DimStyleTableRecord not owned by the database — call Dispose() on it after use to avoid memory leaks: using (var tmp = dim.GetDimstyleData()) { ... }
DimStyleTableRecord.CopyFrom(sourceDstr) copies all dim variable values but overwrites the Name property — reassign dstr.Name immediately after calling CopyFrom()
Related Skills
acad-geometry — Point3d coordinates for dimension definition points
acad-mtext — MText formatting in dimension text overrides
acad-layers — layer assignment for dimension entities