This project has moved. For the latest updates, please go here.

About dimension position when load file.dxf

Feb 18, 2015 at 3:23 PM
Please help me!
When I load a file.dxf, how can I get the dimension position in global coordinate?
Thanks for your project.
Feb 18, 2015 at 5:56 PM
It depends on the dimension type:
  • For AlignedDimension and LinearDimension entities the FirstReferencePoint and SecondReferencePoint properties defines the start and end point of the measured length.
  • For Angular2LineDimension entities the measured angle is defined by two lines which end points are represented by the properties StartFirstLine, EndFirstLine, StartSecondLine, and EndSecondLine.
  • For Angular3PointDimension entities the measured angle is defined by an arc represented by the CenterPoint, StartPoint, and EndPoint properties.
  • For DiametricDimension and RadialDimension entities the CenterPoint and ReferencePoint properties define the center and a point on the circumference, or arc, which diameter or radius is being measured.
  • For OrdinateDimension entities the Origin property represents the position of the dimension.
Feb 19, 2015 at 1:48 AM
I know it, but I do not know how to get FirstReferencePoint and SecondReferencePoint.
For example:

DxfDocument dxf = new DxfDocument();
dxf = DxfDocument.Load(name);

in dxf, I see dxf.Dimensions and dxf.DimensionStyles. But how to point to FirstReferencePoint and SecondReferencePoint.
Thanks again for your great project.
Feb 19, 2015 at 11:52 PM
The dxf.Dimensions will return a ReadOnlyCollection<Dimension> object with the complete list of dimensions contained in the dxf across all layouts. You will need to cast every dimension, from that list, to its actual type to have access to its specific properties. Dimension is the base class from which all dimensions inherit from, and to check its type, you have several ways:
  1. Use the operator "as" or "is" keywords.
  2. Check the DimensionType property defined in the Dimension class.
  3. Or check the type property inherited from EntityObject.
  4. Or even check the CodeName property that is inherited from DxfObject.
I would recommend you to stick with option 1 or 2 since they are more readable and specific to dimension objects. For example:
// pick the dimension you like from the list
Dimension dimension = dxf.Dimensions[0];
// using "is" keyword
if (dimension is AlignedDimension)
    AlignedDimension aligned1 = (AlignedDimension)dimension;
    // now you have access to the specific properties of the AlignedDimension through aligned1
// ... the same with the rest of the Dimension classes, or just the ones you are interested in.

// using "as" keyword
AlignedDimension aligned2 = dimension as AlignedDimension;
if (aligned2 != null)
    // now you have access to the specific properties of the AlignedDimension through aligned2
// ... the same with the rest of the Dimension classes, or just the ones you are interested in.

// using a loop
foreach (Dimension dim in dxf.Dimensions)
    // check the dimension type and cast it to its specific class
    switch (dim.DimensionType)
        case DimensionType.Aligned:
            AlignedDimension aligned = (AlignedDimension) dim;
        case DimensionType.Angular:
            Angular2LineDimension angular = (Angular2LineDimension) dim;
        case DimensionType.Angular3Point:
            Angular3PointDimension angular3Point = (Angular3PointDimension) dim;
        case DimensionType.Diameter:
            DiametricDimension diameter = (DiametricDimension) dim;
        case DimensionType.Linear:
            LinearDimension linear = (LinearDimension) dim;
        case DimensionType.Ordinate:
            OrdinateDimension ordinate = (OrdinateDimension) dim;
        case DimensionType.Radius:
            RadialDimension radius = (RadialDimension) dim;
The dxf.DimensionStyles holds all styles defined in the document. The dimension Style property will point to one in that list.

Feb 20, 2015 at 1:35 AM
Thank you very much.
Feb 25, 2015 at 3:37 PM
Please help me about arrow of dimensions.
I load dxf file to plot line, openGL using in my small project.
With your previous help, I can plot dimension line, dimline by using function Build(LinearDimension dim, string name).
Now I want plotting the arrow.
Can I find information of the arrow, such like for (_OPEN) narrow type: line1, line2, line3 in function (public static Block Open) of DimensionArrowhead class?
Or I must calculate them again?
Sorry for my English.