Class DxfDimension
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
A dimension of a DXF file, as AutoCAD's Dimension: the points it measures between, the text it writes, the style
it is drawn in and the variables of that style it overrides; each kind a class of its own, a
DxfRotatedDimension for a linear one, a DxfRadialDimension for a radius.
public abstract class DxfDimension : DxfEntity
- Inheritance
-
DxfDimension
- Derived
- Inherited Members
Remarks
The points are in world coordinates, as AutoCAD gives them, though the file writes some in the system of the dimension's Normal (the text's place, group 11, and the place of its block, 12). The rotated dimension of 100 from (0, 0, 0) to (100, 0, 0), its dimension line 20 above, has XLine1Point (0, 0, 0), XLine2Point (100, 0, 0), DimLinePoint on the line 20 above and a Measurement of 100, worked out from the points as AutoCAD works it out.
What a dimension is drawn with, its lines, arrowheads and text, is the anonymous block DimBlock
(*D7) that AutoCAD drew for it, placed at DimBlockPosition. The library does not draw a dimension:
a point, a text or a variable set is written into the record, and the block is left as it was drawn, to be drawn anew by
AutoCAD when it next draws the dimension, as its RecomputeDimensionBlock would; until then AutoCAD shows the old
picture. TransformBy(GeoTransform3) moves the points as ezdxf's transform() moves them, and
the picture with them where AutoCAD gives the block to this dimension alone (flag 32 of group 70) and places it at no
point of its own (no group 12): the block's entities moved by the same transformation, so that the dimension is drawn
where it now stands.
A variable of the style, as Dimasz, reads as the dimension draws with it: its own where it overrides the style (its extended data of ACAD, the list DSTYLE of a 1070 naming the variable's group and its value), else its style's, else AutoCAD's own. Set, it is written as an override, as AutoCAD's DIMOVERRIDE writes one; the style is left as it is. A block, linetype or text style set on a dimension of a drawing is one of that drawing; one set on a dimension in no drawing yet is held as the record it is, and taken to the record of its name in the drawing it is added to, as AutoCAD's deep clone maps one, the dimension refused where that drawing has none of that name. A copy added to another drawing keeps its overrides that point at a record, those it read and those set on it, each taken to the record of the same name there, which the drawing is given where it has none, as AutoCAD's deep clone between drawings does. An override of a variable a drawing of an older version has not is left out when the dimension is added to it, as AutoCAD's SAVEAS to that version leaves it out: DIMLTYPE and DIMFXLEN, which R2007 brought, in a drawing of R2000.
A dimension made in code, new DxfRotatedDimension(0, p1, p2, onLine, "", null), is drawn by no block until it is
given one: DimBlock, a block of the drawing it is added to, is needed before
AppendEntity(DxfEntity) takes it. Its picture is a block named *D added to the
drawing, which the block table names as AutoCAD names it, *D1 the first, and marks anonymous, with the lines and
the text appended to it: var picture = new DxfBlockTableRecord { Name = "*D" }; db.BlockTable.Add(picture);,
then a line and an MTEXT appended to picture and the dimension given DimBlock = picture, saved and read
back as AutoCAD writes its own, the BLOCK *D1 of flag 1. A copy added to another drawing brings a copy of its
block where AutoCAD names the block itself (*D1), and needs one of the same name there where it does not. A copy
added to the drawing it came from shares its original's block, and loses flag 32, so that moving the one leaves the
other's picture where it is; one made in code is written with it once given an anonymous block. A copy of a dimension that names no block, as
the dimensions of the constraints of AutoCAD's Parking sample name none in the block and in its anonymous copies,
names none, so that an INSERT of such a dynamic block is set.
Properties
- AltSuppressLeadingZeros
Gets or sets whether leading zeros of alternate units are left out (flag 4 of Dimaltz), as AutoCAD's
AltSuppressLeadingZeros.
- AltSuppressTrailingZeros
Gets or sets whether trailing zeros of alternate units are left out (flag 8 of Dimaltz), as AutoCAD's
AltSuppressTrailingZeros.
- AltSuppressZeroFeet
Gets or sets whether nought feet of alternate units are left out, as AutoCAD's
AltSuppressZeroFeet.
- AltSuppressZeroInches
Gets or sets whether nought inches of alternate units are left out, as AutoCAD's
AltSuppressZeroInches.
- AltToleranceSuppressLeadingZeros
Gets or sets whether leading zeros of tolerances in alternate units are left out (flag 4 of Dimalttz), as AutoCAD's
AltToleranceSuppressLeadingZeros.
- AltToleranceSuppressTrailingZeros
Gets or sets whether trailing zeros of tolerances in alternate units are left out (flag 8 of Dimalttz), as AutoCAD's
AltToleranceSuppressTrailingZeros.
- AltToleranceSuppressZeroFeet
Gets or sets whether nought feet of tolerances in alternate units are left out, as AutoCAD's
AltToleranceSuppressZeroFeet.
- AltToleranceSuppressZeroInches
Gets or sets whether nought inches of tolerances in alternate units are left out, as AutoCAD's
AltToleranceSuppressZeroInches.
- AlternatePrefix
Gets or sets what is written before the measurement in alternate units, as AutoCAD's
AlternatePrefix: of Dimapost, what comes before its[].
- AlternateSuffix
Gets or sets what is written after the measurement in alternate units, as AutoCAD's
AlternateSuffix: of Dimapost, what comes after its[].
- CenterMarkSize
Gets the size of the centre mark, as AutoCAD's
CenterMarkSize: the size of Dimcen, 2.5 for -2.5.
- CenterMarkType
Gets what the centre is marked with, as AutoCAD's
CenterMarkType: by the sign of Dimcen, a mark above nought, a line below, none at nought.
- DimAssoc
Gets the DIMASSOC that ties the dimension's points to objects, as AutoCAD keeps it under ACAD_DIMASSOC in the dimension's extension dictionary; null for a dimension tied to nothing, as one AutoCAD has disassociated.
- DimBlock
Gets or sets the anonymous block that draws the dimension (group 2), as AutoCAD's
DimBlockIdgives its id:*D7, drawn by AutoCAD; null where the record names none, as a dimensional constraint does, or the drawing has no block of its name. A dimension in no drawing yet, copied from one, gives the block of that drawing.
- DimBlockPosition
Gets the point the block that draws the dimension is placed at (group 12, written in the system of the normal), as AutoCAD's
DimBlockPosition: in world coordinates; the origin where the record gives none, the block then drawn where it stands.
- Dimaltrnd
Gets or sets the dimension's Dimaltrnd, as AutoCAD's
Dimaltrnd: its override, else its style's.
- Dimalttd
Gets or sets the dimension's Dimalttd, as AutoCAD's
Dimalttd: its override, else its style's.
- Dimalttz
Gets or sets the dimension's Dimalttz, as AutoCAD's
Dimalttz: its override, else its style's.
- Dimapost
Gets or sets the dimension's Dimapost, as AutoCAD's
Dimapost: its override, else its style's.
- Dimarcsym
Gets or sets the dimension's Dimarcsym, as AutoCAD's
Dimarcsym: its override, else its style's.
- Dimasz
Gets or sets the dimension's Dimasz, as AutoCAD's
Dimasz: its override, else its style's; 4.5 where it overrides the style's 2.5 with 4.5 (1070 41, 1040 4.5).
- Dimatfit
Gets or sets the dimension's Dimatfit, as AutoCAD's
Dimatfit: its override, else its style's.
- Dimaunit
Gets or sets the dimension's Dimaunit, as AutoCAD's
Dimaunit: its override, else its style's.
- Dimblk
Gets or sets the dimension's Dimblk, as AutoCAD's
Dimblk: its override (1005 the block's handle, or 1000 its name in a file of R12), else its style's; null for the closed filled arrowhead.
- DimensionStyle
Gets or sets the style the dimension is drawn in, as AutoCAD's
DimensionStylegives its id: the record of the drawing's DimStyleTable named by DimensionStyleName; null where the drawing has none of that name, or the dimension is in no drawing.
- DimensionStyleName
Gets or sets the name of the style the dimension is drawn in (group 3), as AutoCAD's
DimensionStyleName;Standardwhere the record gives none.
- DimensionText
Gets or sets the text the dimension writes (group 1), as AutoCAD's
DimensionText: empty or<>for the measurement,<> TYPfor the measurement and TYP after it, a single space for none; each escape of four digits read as the letter it stands for, as AutoCAD 2021 reads it,<> \U+0110giving <> Đ; empty where the record gives none.
- Dimfxlen
Gets or sets the dimension's Dimfxlen, as AutoCAD's
Dimfxlen: its override, else its style's.
- DimfxlenOn
Gets or sets the dimension's DimfxlenOn, as AutoCAD's
DimfxlenOn: its override, else its style's.
- Dimjogang
Gets or sets the dimension's Dimjogang in radians, as AutoCAD's
Dimjogang: its override (in radians, as AutoCAD keeps it), else its style's.
- Dimldrblk
Gets or sets the dimension's Dimldrblk, as AutoCAD's
Dimldrblk: its override, else its style's.
- Dimltex1
Gets or sets the dimension's Dimltex1, as AutoCAD's
Dimltex1: its override, else its style's.
- Dimltex2
Gets or sets the dimension's Dimltex2, as AutoCAD's
Dimltex2: its override, else its style's.
- Dimltype
Gets or sets the dimension's Dimltype, as AutoCAD's
Dimltype: its override, else its style's.
- Dimlunit
Gets or sets the dimension's Dimlunit, as AutoCAD's
Dimlunit: its override, else its style's.
- Dimscale
Gets or sets the dimension's Dimscale, as AutoCAD's
Dimscale: its override, else its style's.
- Dimtfill
Gets or sets the dimension's Dimtfill, as AutoCAD's
Dimtfill: its override, else its style's.
- Dimtfillclr
Gets or sets the dimension's Dimtfillclr, as AutoCAD's
Dimtfillclr: its override (1070 70), else its style's.
- Dimtmove
Gets or sets the dimension's Dimtmove, as AutoCAD's
Dimtmove: its override, else its style's.
- Dimtxtdirection
Gets or sets the dimension's Dimtxtdirection, as AutoCAD's
Dimtxtdirection: its override (1070 294), else its style's.
- Elevation
Gets or sets how far the dimension stands along its normal, as AutoCAD's
Elevation: the third coordinate of its text's place (group 31) in the system of the normal, where ezdxf takes it from too.
- GeometricExtents
Gets the box the dimension's picture fills where it stands, as AutoCAD 2021's
GeometricExtentsof a dimension: that of every entity of its block (DimBlock) placed as Explode() places them, the points on the layer Defpoints that mark where it measures among them, which Explode() leaves out. A level dimension from (0, 0, 0) to (100, 0, 0) with its line at y 20 fills (0, 0, 0) to (100, 20.18, 0): the points at its ends reach down to y 0, its extension lines up to 20.18. The words of the picture are measured as GeometricExtents measures a text; one the drawing's fonts do not measure adds nothing.
- HorizontalRotation
Gets or sets the direction AutoCAD takes as level for the dimension (group 51, in degrees), as AutoCAD's
HorizontalRotation: in radians, the negative of the angle from the x of the normal's system to that of the user's; nought where the record gives none.
- Measurement
Gets the measurement of the dimension, as AutoCAD's
Measurement: worked out from its points, as AutoCAD works it out, a length or, for an angular dimension, an angle in radians; the 100 between (0, 0, 0) and (100, 0, 0) of a rotated dimension along x. The measurement AutoCAD wrote with the block it drew (group 42) agrees with it until a point is moved.
- Normal
Gets or sets the normal of the plane the dimension lies in (groups 210, 220, 230), as AutoCAD's
Normal; of unit length, (0, 0, 1) where the record gives none.
- Prefix
Gets or sets what is written before the measurement, as AutoCAD's
Prefix: of Dimpost, what comes before its<>, Ø ofØ<> mm; empty where it has none.
- Suffix
Gets or sets what is written after the measurement, as AutoCAD's
Suffix: of Dimpost, what comes after its<>, " mm" ofØ<> mm, or the whole of one that has none.
- SuppressAngularLeadingZeros
Gets or sets whether leading zeros of angles are left out (flag 1 of Dimazin), as AutoCAD's
SuppressAngularLeadingZeros.
- SuppressAngularTrailingZeros
Gets or sets whether trailing zeros of angles are left out (flag 2 of Dimazin), as AutoCAD's
SuppressAngularTrailingZeros.
- SuppressLeadingZeros
Gets or sets whether leading zeros of decimal lengths are left out (flag 4 of Dimzin), as AutoCAD's
SuppressLeadingZeros: .5 for 0.5.
- SuppressTrailingZeros
Gets or sets whether trailing zeros of decimal lengths are left out (flag 8 of Dimzin), as AutoCAD's
SuppressTrailingZeros: 12.5 for 12.50.
- SuppressZeroFeet
Gets or sets whether nought feet are left out (Dimzin of 0 or 3), as AutoCAD's
SuppressZeroFeet.
- SuppressZeroInches
Gets or sets whether nought inches are left out (Dimzin of 0 or 2), as AutoCAD's
SuppressZeroInches.
- TextAttachment
Gets or sets where the text is held by its point, as AutoCAD's
TextAttachment(group 71, from R2000 on); MiddleCenter where the record gives none.
- TextLineSpacingFactor
Gets or sets the spacing of the text's lines for AutoCAD's own, as AutoCAD's
TextLineSpacingFactor(group 41 of AcDbDimension, from R2000 on): 1.5 spaces them half again as far; 1 where the record gives none.
- TextLineSpacingStyle
Gets or sets how the spacing of the text's lines is taken, as AutoCAD's
TextLineSpacingStyle(group 72, from R2000 on); AtLeast where the record gives none.
- TextPosition
Gets or sets the middle of the text (group 11, written in the system of the normal), as AutoCAD's
TextPosition: in world coordinates; the origin where the record gives none.
- TextRotation
Gets or sets the turn of the text from the direction of the dimension line (group 53, in degrees), as AutoCAD's
TextRotation: in radians; nought where the record gives none.
- TextStyle
Gets or sets the text style of the text, as AutoCAD's
TextStyleIdgives its id: the style's Dimtxsty or the dimension's override of it (340); null where neither names one.
- ToleranceSuppressLeadingZeros
Gets or sets whether leading zeros of tolerances are left out (flag 4 of Dimtzin), as AutoCAD's
ToleranceSuppressLeadingZeros.
- ToleranceSuppressTrailingZeros
Gets or sets whether trailing zeros of tolerances are left out (flag 8 of Dimtzin), as AutoCAD's
ToleranceSuppressTrailingZeros.
- ToleranceSuppressZeroFeet
Gets or sets whether nought feet of tolerances are left out, as AutoCAD's
ToleranceSuppressZeroFeet.
- ToleranceSuppressZeroInches
Gets or sets whether nought inches of tolerances are left out, as AutoCAD's
ToleranceSuppressZeroInches.
- UsingDefaultTextPosition
Gets or sets whether the text stands where the style puts it (flag 128 of group 70 not set), as AutoCAD's
UsingDefaultTextPosition.
Methods
- Explode()
Gets the entities the dimension is drawn with, as AutoCAD's
Explode: those of its block (DimBlock,*D7) placed where the dimension draws them, as ezdxf'svirtual_entities()places them, each a copy of its own look; moved by DimBlockPosition, and carried from the system of the dimension's Normal to the world at the height of its text where that is not the world's. The points of its block on the layer Defpoints, which mark where it measures, are left out, as AutoCAD 2021'sExplodeleaves them: a dimension whose block holds two lines, two arrows, a text and three such points explodes into five entities. The block is the picture AutoCAD drew last: a point set on the dimension since is not in it.
- FieldFromMText(DxfMText)
Gives the dimension's text the field of an MTEXT, as AutoCAD's
FieldFromMText: a copy of the MTEXT's field of its words (GetField()) and its children, every group of them kept, given to the dimension's words as SetField(DxfField) gives one, in the place of the field it had; where the MTEXT has none, the dimension's is taken out, so that the two agree. The text the dimension writes (1) is not changed.
- FieldToMText(DxfMText)
Gives an MTEXT the field of the dimension's text, as AutoCAD's
FieldToMText: a copy of the dimension's field of its words and its children, every group of them kept, given to the MTEXT's words in the place of the field it had; where the dimension has none, the MTEXT's is taken out. The MTEXT's Contents are not changed.
- FormatMeasurement(double, string)
Gets the text the dimension writes for a measurement, as AutoCAD's
FormatMeasurement: the measurement in the units and to the places of the variables it reads, put into a text as its own text is. A length is multiplied by Dimlfac (a negative one taken as its size in paper space and as 1 elsewhere, as AutoCAD takes it), rounded by Dimrnd and written in Dimlunit: 1 scientific, 2 decimal, 3 engineering, 4 architectural, 5 fractional, 6 as the Windows desktop writes it under the culture of the thread; to Dimdec places, or in architectural and fractional units to a fraction of 2 to the power of them, stacked as Dimfrac says in AutoCAD's codes of an MTEXT; its zeros left out as Dimzin says, Dimdsep its decimal separator, Dimpost about it; and where Dimalt is on, its alternate units after it in brackets, or in the place of a[]of the text. An angle, of a DxfLineAngularDimension2 or a DxfPoint3AngularDimension, is given in radians and written in Dimaunit (0 decimal degrees, 1 degrees, minutes and seconds, 2 grads, 3 radians) to Dimadec places (those of Dimdec at -1), its zeros left out as Dimazin says. In the style ISO-25, two places, a comma and trailing zeros left out, 1234.5 is1234,5and 60 is60; in architectural units to a sixteenth, not stacked, 15.5 is1'-3 1/2"; to two decimal places 2.675 is2.68, a number being rounded as its 15 significant figures (a .NET decimal), half away from nought; pi / 4 of an angular dimension is45°. Tolerances, limits, the arc symbol and the R or diameter sign before a radius are not part of it.
- GetDimstyleData()
Gets the variables the dimension is drawn with, as AutoCAD's
GetDimstyleData: a new DxfDimStyleTableRecord in no table, named as the dimension's style, each variable as the dimension reads it, its override or its style's.
- ReleaseDimAssoc()
Unties the dimension from the objects its points were tied to, as AutoCAD disassociates it (DIMDISASSOCIATE, or the last object it was tied to erased): the DIMASSOC taken out of the reactors of each object and of the dimension and erased, and the extension dictionary released where it is left empty, as AutoCAD leaves a dimension with none. The dimension keeps its points and its picture. Nothing for a dimension tied to nothing.
- RemoveTextField()
Takes out the field of the dimension's text, as AutoCAD's
RemoveTextField: as RemoveField() takes it out, with its children, the text the dimension writes (1) kept. Nothing where it has none.
- SetDimAssoc(IEnumerable<DxfOsnapPointRef>)
Ties the dimension's points to objects, as AutoCAD 2021 ties a dimension made with DIMASSOC 2 by object snaps: a DIMASSOC under ACAD_DIMASSOC in the dimension's extension dictionary (made where it has none), owned by the dictionary, naming the dimension and each reference, and listed among the reactors of the dimension and of every object it names; the class DIMASSOC listed. A dimension tied already has its DIMASSOC written anew, the same handle, an object it no longer names losing the reactor. A DIMLINEAR from the start of the line 2A to its end is tied by
dimension.SetDimAssoc(new[] { new DxfOsnapPointRef(0, DxfOsnapType.StartPoint, "2A", 0, 0, start, null), new DxfOsnapPointRef(1, DxfOsnapType.Endpoint, "2A", 0, 1, end, null) }). The dimension's points are not moved: they are where the references say already.
- SetDimstyleData(DxfDimStyleTableRecord)
Gives the dimension the variables of a record, as AutoCAD's
SetDimstyleData: each that differs from what the dimension reads written as an override, as its setter writes one; those the dimension reads already change nothing. A variable its file's version has not is passed over where the record holds AutoCAD's own value of it, and refused where it holds another; a record that names no text style leaves the dimension's as it is. A whole number is checked against AutoCAD's range as SetDimstyleData(DxfDimStyleTableRecord) checks it, aDimdecof 9 refused, and a size of the arrows, the text or the scale below nought. Every value is checked before any is written.
- SetFromStyle()
Takes away the dimension's overrides of its dimension style, as AutoCAD's
SetFromStyle: the list DSTYLE of its extended data of ACAD, the rest of that data kept, and the data of ACAD with it where nothing else is left; each variable then reads as its style has it, a dimension ofDimasz4.5 of its own over a style of 3.5 reading 3.5. A dimension of no overrides changes nothing. The block AutoCAD drew the dimension with is not drawn anew.