/// <summary>
 /// Initializes a new instance of the <c>OrdinateDimension</c> class.
 /// </summary>
 /// <param name="origin">Origin <see cref="Vector3">point</see> in world coordinates of the ordinate dimension.</param>
 /// <param name="referencePoint">Base location <see cref="Vector3">point</see> in local coordinates of the ordinate dimension.</param>
 /// <param name="length">Length of the dimension line.</param>
 /// <param name="axis">Local axis that measures the ordinate dimension.</param>
 /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks>
 public OrdinateDimension(Vector3 origin, Vector2 referencePoint, double length, OrdinateDimensionAxis axis, double rotation, DimensionStyle style)
     : base(DimensionType.Ordinate)
 {
     this.origin = origin;
     this.rotation = MathHelper.NormalizeAngle(rotation);
     this.length = length;
     this.referencePoint = referencePoint;
     this.axis = axis;
     this.style = style;
 }
 protected virtual DimensionStyle OnDimensionStyleChangedEvent(DimensionStyle oldStyle, DimensionStyle newStyle)
 {
     DimensionStyleChangedEventHandler ae = this.DimensionStyleChanged;
     if (ae != null)
     {
         TableObjectChangedEventArgs<DimensionStyle> eventArgs = new TableObjectChangedEventArgs<DimensionStyle>(oldStyle, newStyle);
         ae(this, eventArgs);
         return eventArgs.NewValue;
     }
     return newStyle;
 }
 /// <summary>
 /// Initializes a new instance of the <c>RadialDimension</c> class.
 /// </summary>
 /// <param name="arc"><see cref="Arc">Arc</see> to measure.</param>
 /// <param name="rotation">Rotation in degrees of the dimension line.</param>
 /// <param name="offset">Distance between the reference point and the dimension text</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The center point and the definition point define the distance to be measure.</remarks>
 public RadialDimension(Arc arc, double rotation, double offset, DimensionStyle style)
     : base(DimensionType.Radius)
 {
     double angle = rotation * MathHelper.DegToRad;
     Vector3 point = MathHelper.Transform(new Vector3(arc.Radius * Math.Sin(angle), arc.Radius * Math.Cos(angle), 0.0), arc.Normal, MathHelper.CoordinateSystem.Object, MathHelper.CoordinateSystem.World);
     this.center = arc.Center;
     this.refPoint = arc.Center + point;
     this.offset = offset;
     if (style == null)
         throw new ArgumentNullException("style", "The Dimension style cannot be null.");
     this.style = style;
 }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <c>OrdinateDimension</c> class.
        /// </summary>
        /// <param name="origin">Origin <see cref="Vector3">point</see> in world coordinates of the ordinate dimension.</param>
        /// <param name="referencePoint">Base location <see cref="Vector3">point</see> in local coordinates of the ordinate dimension.</param>
        /// <param name="length">Length of the dimension line.</param>
        /// <param name="axis">Local axis that measures the ordinate dimension.</param>
        /// <param name="rotation">Angle of rotation in degrees of the dimension lines.</param>
        /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
        /// <remarks>The local coordinate system of the dimension is defined by the dimension normal and the rotation value.</remarks>
        public OrdinateDimension(Vector2 origin, Vector2 referencePoint, double length, OrdinateDimensionAxis axis, double rotation, DimensionStyle style)
            : base(DimensionType.Ordinate)
        {
            this.origin = origin;
            this.rotation = MathHelper.NormalizeAngle(rotation);
            this.length = length;
            this.referencePoint = referencePoint;
            this.axis = axis;

            if (style == null)
                throw new ArgumentNullException(nameof(style));
            this.Style = style;
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <c>DiametricDimension</c> class.
        /// </summary>
        /// <param name="arc"><see cref="Arc">Arc</see> to measure.</param>
        /// <param name="rotation">Rotation in degrees of the dimension line.</param>
        /// <param name="offset">Distance between the reference point and the dimension text</param>
        /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
        /// <remarks>The center point and the definition point define the distance to be measure.</remarks>
        public DiametricDimension(Arc arc, double rotation, double offset, DimensionStyle style)
            : base(DimensionType.Diameter)
        {
            if (arc == null)
                throw new ArgumentNullException(nameof(arc));

            Vector3 ocsCenter = MathHelper.Transform(arc.Center, arc.Normal, CoordinateSystem.World, CoordinateSystem.Object);
            this.center = new Vector2(ocsCenter.X, ocsCenter.Y);
            this.refPoint = Vector2.Polar(this.center, arc.Radius, rotation*MathHelper.DegToRad);
            this.offset = offset;

            if (style == null)
                throw new ArgumentNullException(nameof(style));
            this.Style = style;
            this.Normal = arc.Normal;
            this.Elevation = ocsCenter.Z;
        }
 /// <summary>
 /// Initializes a new instance of the <c>Leader</c> class.
 /// </summary>
 public Leader(IList<Vector2> vertexes, DimensionStyle style)
     : base(EntityType.Leader, DxfObjectCode.Leader)
 {
     if (vertexes == null)
         throw new ArgumentNullException(nameof(vertexes));
     if (vertexes.Count < 2)
         throw new ArgumentOutOfRangeException(nameof(vertexes), "The leader vertexes list requires at least two points.");
     this.vertexes = new List<Vector2>(vertexes);
     this.style = style;
     this.hasHookline = false;
     this.showArrowhead = true;
     this.pathType = LeaderPathType.StraightLineSegements;
     this.annotation = null;
     this.textPosition = LeaderTextVerticalPosition.Above;
     this.lineColor = AciColor.ByLayer;
     this.elevation = 0.0;
     this.offset = Vector2.Zero;
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <c>Dimension</c> class.
 /// </summary>
 protected Dimension(DimensionType type)
     : base(EntityType.Dimension, DxfObjectCode.Dimension)
 {
     this.definitionPoint = Vector3.Zero;
     this.midTextPoint = Vector3.Zero;
     this.dimensionType = type;
     this.attachmentPoint = MTextAttachmentPoint.MiddleCenter;
     this.lineSpacingStyle = MTextLineSpacingStyle.AtLeast;
     this.lineSpacing = 1.0;
     this.block = null;
     this.style = DimensionStyle.Default;
     this.userText = null;
     this.elevation = 0.0;
     this.styleOverrides = new DimensionStyleOverrideDictionary();
     this.styleOverrides.BeforeAddItem += this.StyleOverrides_BeforeAddItem;
     this.styleOverrides.AddItem += this.StyleOverrides_AddItem;
     this.styleOverrides.BeforeRemoveItem += this.StyleOverrides_BeforeRemoveItem;
     this.styleOverrides.RemoveItem += this.StyleOverrides_RemoveItem;
 }
        /// <summary>
        /// Initializes a new instance of the <c>Angular3PointDimension</c> class.
        /// </summary>
        /// <param name="arc">Angle <see cref="Arc">arc</see> to measure.</param>
        /// <param name="offset">Distance between the center of the arc and the dimension line.</param>
        /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
        public Angular3PointDimension(Arc arc, double offset, DimensionStyle style)
            : base(DimensionType.Angular3Point)
        {
            if (arc == null)
                throw new ArgumentNullException(nameof(arc));

            Vector3 refPoint = MathHelper.Transform(arc.Center, arc.Normal, CoordinateSystem.World, CoordinateSystem.Object);
            this.center = new Vector2(refPoint.X, refPoint.Y);
            this.start = Vector2.Polar(this.center, arc.Radius, arc.StartAngle*MathHelper.DegToRad);
            this.end = Vector2.Polar(this.center, arc.Radius, arc.EndAngle*MathHelper.DegToRad);

            if (MathHelper.IsZero(offset))
                throw new ArgumentOutOfRangeException(nameof(offset), "The offset value cannot be zero.");
            this.offset = offset;

            if (style == null)
                throw new ArgumentNullException(nameof(style));
            this.Style = style;
            this.Normal = arc.Normal;
            this.Elevation = refPoint.Z;
        }
        /// <summary>
        /// Initializes a new instance of the <c>Angular3PointDimension</c> class.
        /// </summary>
        /// <param name="arc">Angle <see cref="Arc">arc</see> to measure.</param>
        /// <param name="offset">Distance between the center of the arc and the dimension line.</param>
        /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
        public Angular3PointDimension(Arc arc, double offset, DimensionStyle style)
            : base(DimensionType.Angular3Point)
        {
            this.center = arc.Center;

            Vector3 refPoint = MathHelper.Transform(arc.Center, arc.Normal, MathHelper.CoordinateSystem.World, MathHelper.CoordinateSystem.Object);

            Vector2 centerRef = new Vector2(refPoint.X, refPoint.Y);
            double elev = refPoint.Z;

            Vector2 ref1 = Vector2.Polar(centerRef, arc.Radius, arc.StartAngle * MathHelper.DegToRad);
            this.start = MathHelper.Transform(new Vector3(ref1.X, ref1.Y, elev), arc.Normal, MathHelper.CoordinateSystem.Object, MathHelper.CoordinateSystem.World);

            Vector2 ref2 = Vector2.Polar(centerRef, arc.Radius, arc.EndAngle * MathHelper.DegToRad);
            this.end = MathHelper.Transform(new Vector3(ref2.X, ref2.Y, elev), arc.Normal, MathHelper.CoordinateSystem.Object, MathHelper.CoordinateSystem.World);

            if (MathHelper.IsZero(offset))
                throw new ArgumentOutOfRangeException("offset", "The offset value cannot be zero.");
            this.offset = offset;

            if (style == null)
                throw new ArgumentNullException("style", "The Dimension style cannot be null.");
            this.style = style;      
        }
        /// <summary>
        /// Initializes a new instance of the <c>RadialDimension</c> class.
        /// </summary>
        /// <param name="centerPoint">Center <see cref="Vector3">point</see> of the circumference.</param>
        /// <param name="referencePoint"><see cref="Vector3">Point</see> on circle or arc.</param>
        /// <param name="offset">Distance between the reference point and the dimension text</param>
        /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
        /// <remarks>The center point and the definition point define the distance to be measure.</remarks>
        public RadialDimension(Vector3 centerPoint, Vector3 referencePoint, double offset, DimensionStyle style)
            : base(DimensionType.Radius)
        {
            this.center = centerPoint;
            this.refPoint = referencePoint;

            if (offset < 0.0)
                throw new ArgumentOutOfRangeException("offset", "The offset value cannot be negative.");
            this.offset = offset;

            if (style == null)
                throw new ArgumentNullException("style", "The Dimension style cannot be null.");
            this.style = style;
        }
 /// <summary>
 /// Initializes a new instance of the <c>RadialDimension</c> class.
 /// </summary>
 /// <param name="centerPoint">Center <see cref="Vector2">point</see> of the circumference.</param>
 /// <param name="referencePoint"><see cref="Vector2">Point</see> on circle or arc.</param>
 /// <param name="offset">Distance between the reference point and the dimension text</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The center point and the definition point define the distance to be measure.</remarks>
 public RadialDimension(Vector2 centerPoint, Vector2 referencePoint, double offset, DimensionStyle style)
     : this(new Vector3(centerPoint.X, centerPoint.Y, 0.0), new Vector3(referencePoint.X, referencePoint.Y, 0.0), offset, style)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <c>RadialDimension</c> class.
        /// </summary>
        /// <param name="circle"><see cref="Circle">Circle</see> to measure.</param>
        /// <param name="rotation">Rotation in degrees of the dimension line.</param>
        /// <param name="offset">Distance between the reference point and the dimension text</param>
        /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
        /// <remarks>The center point and the definition point define the distance to be measure.</remarks>
        public RadialDimension(Circle circle, double rotation, double offset, DimensionStyle style)
            : base(DimensionType.Radius)
        {
            double angle = rotation*MathHelper.DegToRad;
            Vector3 point = MathHelper.Transform(new Vector3(circle.Radius * Math.Cos(angle), circle.Radius * Math.Sin(angle), 0.0), circle.Normal, MathHelper.CoordinateSystem.Object, MathHelper.CoordinateSystem.World);
            this.center = circle.Center;
            this.refPoint = circle.Center + point;

            if (offset < 0.0)
                throw new ArgumentOutOfRangeException("offset", "The offset value cannot be negative.");
            this.offset = offset;

            if (style == null)
                throw new ArgumentNullException("style", "The Dimension style cannot be null.");
            this.style = style;
        }
        /// <summary>
        /// Writes a new dimension style to the table section.
        /// </summary>
        /// <param name="style">DimensionStyle.</param>
        private void WriteDimensionStyle(DimensionStyle style)
        {
            Debug.Assert(this.activeTable == DxfObjectCode.DimensionStyleTable);

            this.chunk.Write(0, style.CodeName);
            this.chunk.Write(105, style.Handle);
            this.chunk.Write(330, style.Owner.Handle);

            this.chunk.Write(100, SubclassMarker.TableRecord);

            this.chunk.Write(100, SubclassMarker.DimensionStyle);

            this.chunk.Write(2, this.EncodeNonAsciiCharacters(style.Name));

            // flags
            this.chunk.Write(70, (short) 0);

            this.chunk.Write(3, this.EncodeNonAsciiCharacters(style.DIMPOST));
            this.chunk.Write(40, style.DIMSCALE);
            this.chunk.Write(41, style.DIMASZ);
            this.chunk.Write(42, style.DIMEXO);
            this.chunk.Write(43, style.DIMDLI);
            this.chunk.Write(44, style.DIMEXE);
            this.chunk.Write(45, style.DIMRND);
            this.chunk.Write(46, style.DIMDLE);

            this.chunk.Write(73, style.DIMTIH);
            this.chunk.Write(74, style.DIMTOH);
            if (style.DIMSE1)
                this.chunk.Write(75, (short) 1);
            else
                this.chunk.Write(75, (short) 0);
            if (style.DIMSE2)
                this.chunk.Write(76, (short) 1);
            else
                this.chunk.Write(76, (short) 0);
            this.chunk.Write(77, style.DIMTAD);

            short linSupress = 0;
            if (style.DIMLUNIT == LinearUnitType.Architectural || style.DIMLUNIT == LinearUnitType.Engineering)
            {
                if (style.SuppressZeroFeet && style.SuppressZeroFeet)
                    linSupress = 0;
                else if (!style.SuppressZeroFeet && !style.SuppressZeroFeet)
                    linSupress = 1;
                else if (!style.SuppressZeroFeet && style.SuppressZeroFeet)
                    linSupress = 2;
                else if (style.SuppressZeroFeet && !style.SuppressZeroFeet)
                    linSupress = 3;
            }

            if (!style.SuppressLinearLeadingZeros && !style.SuppressLinearTrailingZeros)
                linSupress += 0;
            else if (style.SuppressLinearLeadingZeros && !style.SuppressLinearTrailingZeros)
                linSupress += 4;
            else if (!style.SuppressLinearLeadingZeros && style.SuppressLinearTrailingZeros)
                linSupress += 8;
            else if (style.SuppressLinearLeadingZeros && style.SuppressLinearTrailingZeros)
                linSupress += 12;
                  
            this.chunk.Write(78, linSupress);

            short angSupress = 3;
            if (style.SuppressAngularLeadingZeros && style.SuppressAngularTrailingZeros)
                angSupress = 3;
            else if (!style.SuppressAngularLeadingZeros && !style.SuppressAngularTrailingZeros)
                angSupress = 0;
            else if (!style.SuppressAngularLeadingZeros && style.SuppressAngularTrailingZeros)
                angSupress = 2;
            else if (style.SuppressAngularLeadingZeros && !style.SuppressAngularTrailingZeros)
                angSupress = 1;

            this.chunk.Write(79, angSupress);

            this.chunk.Write(140, style.DIMTXT);
            this.chunk.Write(141, style.DIMCEN);
            this.chunk.Write(144, style.DIMLFAC);
            this.chunk.Write(147, style.DIMGAP);
            if (style.DIMSAH)
                this.chunk.Write(173, (short) 1);
            else
                this.chunk.Write(173, (short) 0);
            this.chunk.Write(176, style.DIMCLRD.Index);
            this.chunk.Write(177, style.DIMCLRE.Index);
            this.chunk.Write(178, style.DIMCLRT.Index);
            this.chunk.Write(179, style.DIMADEC);
            this.chunk.Write(271, style.DIMDEC);
            this.chunk.Write(275, (short)style.DIMAUNIT);
            this.chunk.Write(276, (short)style.DIMFRAC);
            this.chunk.Write(277, (short)style.DIMLUNIT);
            this.chunk.Write(278, (short)style.DIMDSEP);
            this.chunk.Write(280, style.DIMJUST);

            this.chunk.Write(340, style.DIMTXSTY.Handle);

            // CAUTION: The documentation says that the next three values are the handles of referenced BLOCK,
            // but they are the handles of referenced BLOCK_RECORD
            if (style.DIMLDRBLK != null)
                this.chunk.Write(341, style.DIMLDRBLK.Record.Handle);
            if (style.DIMBLK != null)
                this.chunk.Write(342, style.DIMBLK.Record.Handle);
            if (style.DIMBLK1 != null)
                this.chunk.Write(343, style.DIMBLK1.Record.Handle);
            if (style.DIMBLK2 != null)
                this.chunk.Write(344, style.DIMBLK2.Record.Handle);

            // CAUTION: The next three codes are undocumented in the official dxf docs
            this.chunk.Write(345, style.DIMLTYPE.Handle);
            this.chunk.Write(346, style.DIMLTEX1.Handle);
            this.chunk.Write(347, style.DIMLTEX2.Handle);

            this.chunk.Write(371, style.DIMLWD.Value);
            this.chunk.Write(372, style.DIMLWE.Value);
        }
 static DimensionStyle()
 {
     standard = new DimensionStyle("Standard");
 }
Exemple #15
0
        /// <summary>
        /// Creates a new DimensionStyle that is a copy of the current instance.
        /// </summary>
        /// <param name="newName">DimensionStyle name of the copy.</param>
        /// <returns>A new DimensionStyle that is a copy of this instance.</returns>
        public override TableObject Clone(string newName)
        {
            DimensionStyle copy = new DimensionStyle(newName)
            {
                // dimension lines
                DimLineColor       = (AciColor)this.dimclrd.Clone(),
                DimLineLinetype    = (Linetype)this.dimltype.Clone(),
                DimLineLineweight  = this.dimlwd,
                DimLine1Off        = this.dimsd1,
                DimLine2Off        = this.dimsd2,
                DimBaselineSpacing = this.dimdli,
                DimLineExtend      = this.dimdle,

                // extension lines
                ExtLineColor      = (AciColor)this.dimclre.Clone(),
                ExtLine1Linetype  = (Linetype)this.dimltex1.Clone(),
                ExtLine2Linetype  = (Linetype)this.dimltex2.Clone(),
                ExtLineLineweight = this.dimlwe,
                ExtLine1Off       = this.dimse1,
                ExtLine2Off       = this.dimse2,
                ExtLineOffset     = this.dimexo,
                ExtLineExtend     = this.dimexe,

                // symbols and arrows
                ArrowSize      = this.dimasz,
                CenterMarkSize = this.dimcen,
                LeaderArrow    = (Block)this.dimldrblk?.Clone(),
                DimArrow1      = (Block)this.dimblk1?.Clone(),
                DimArrow2      = (Block)this.dimblk2?.Clone(),

                // text appearance
                TextStyle               = (TextStyle)this.dimtxsty.Clone(),
                TextColor               = (AciColor)this.dimclrt.Clone(),
                TextFillColor           = (AciColor)this.dimtfillclr?.Clone(),
                TextHeight              = this.dimtxt,
                TextHorizontalPlacement = this.dimjust,
                TextVerticalPlacement   = this.dimtad,
                TextOffset              = this.dimgap,
                TextFractionHeightScale = this.dimtfac,

                // fit
                FitDimLineForce  = this.dimtofl,
                FitDimLineInside = this.dimsoxd,
                DimScaleOverall  = this.dimscale,
                FitOptions       = this.dimatfit,
                FitTextInside    = this.dimtix,
                FitTextMove      = this.dimtmove,

                // primary units
                AngularPrecision             = this.dimadec,
                LengthPrecision              = this.dimdec,
                DimPrefix                    = this.dimPrefix,
                DimSuffix                    = this.dimSuffix,
                DecimalSeparator             = this.dimdsep,
                DimScaleLinear               = this.dimlfac,
                DimLengthUnits               = this.dimlunit,
                DimAngularUnits              = this.dimaunit,
                FractionType                 = this.dimfrac,
                SuppressLinearLeadingZeros   = this.suppressLinearLeadingZeros,
                SuppressLinearTrailingZeros  = this.suppressLinearTrailingZeros,
                SuppressZeroFeet             = this.suppressZeroFeet,
                SuppressZeroInches           = this.suppressZeroInches,
                SuppressAngularLeadingZeros  = this.suppressAngularLeadingZeros,
                SuppressAngularTrailingZeros = this.suppressAngularTrailingZeros,
                DimRoundoff                  = this.dimrnd,

                // alternate units
                AlternateUnits = (DimensionStyleAlternateUnits)this.alternateUnits.Clone(),

                // tolerances
                Tolerances = (DimensionStyleTolerances)this.tolerances.Clone()
            };

            foreach (XData data in this.XData.Values)
            {
                copy.XData.Add((XData)data.Clone());
            }

            return(copy);
        }
 /// <summary>
 /// Initializes a new instance of the <c>Dimension</c> class.
 /// </summary>
 protected Dimension(DimensionType type)
     : base(EntityType.Dimension, DxfObjectCode.Dimension)
 {
     this.definitionPoint = Vector3.Zero;
     this.midTextPoint = Vector3.Zero;
     this.dimensionType = type;
     this.attachmentPoint = MTextAttachmentPoint.MiddleCenter;
     this.lineSpacingStyle = MTextLineSpacingStyle.AtLeast;
     this.lineSpacing = 1.0;
     this.block = null;
     this.style = DimensionStyle.Default;
     this.userText = null;
 }
 /// <summary>
 /// Initializes a new instance of the <c>Angular2LineDimension</c> class.
 /// </summary>
 /// <param name="firstLine">First <see cref="Line">line</see> that defines the angle to measure.</param>
 /// <param name="secondLine">Second <see cref="Line">line</see> that defines the angle to measure.</param>
 /// <param name="offset">Distance between the center point and the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 public Angular2LineDimension(Line firstLine, Line secondLine, double offset, DimensionStyle style)
     : this(firstLine, secondLine, offset, Vector3.UnitZ, style)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <c>Angular2LineDimension</c> class.
 /// </summary>
 /// <param name="firstLine">First <see cref="Line">line</see> that defines the angle to measure.</param>
 /// <param name="secondLine">Second <see cref="Line">line</see> that defines the angle to measure.</param>
 /// <param name="offset">Distance between the center point and the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 public Angular2LineDimension(Line firstLine, Line secondLine, double offset, DimensionStyle style)
     : this(firstLine.StartPoint, firstLine.EndPoint, secondLine.StartPoint, secondLine.EndPoint, offset, style)
 {
 }
        /// <summary>
        /// Creates a new DimensionStyle that is a copy of the current instance.
        /// </summary>
        /// <param name="newName">DimensionStyle name of the copy.</param>
        /// <returns>A new DimensionStyle that is a copy of this instance.</returns>
        public override TableObject Clone(string newName)
        {
            DimensionStyle copy = new DimensionStyle(newName)
            {
                // dimension lines
                DIMCLRD  = (AciColor)this.dimclrd.Clone(),
                DIMLTYPE = (LineType)this.dimltype.Clone(),
                DIMLWD   = (Lineweight)this.dimlwd.Clone(),
                DIMDLI   = this.dimdli,
                DIMDLE   = this.dimdle,

                // extension lines
                DIMCLRE  = (AciColor)this.dimclre.Clone(),
                DIMLTEX1 = (LineType)this.dimltex1.Clone(),
                DIMLTEX2 = (LineType)this.dimltex2.Clone(),
                DIMLWE   = (Lineweight)this.dimlwe.Clone(),
                DIMSE1   = this.dimse1,
                DIMSE2   = this.dimse2,
                DIMEXO   = this.dimexo,
                DIMEXE   = this.dimexe,

                // symbols and arrows
                DIMASZ = this.dimasz,
                DIMCEN = this.dimcen,
                DIMSAH = this.dimsah,

                // fit
                DIMSCALE = this.dimscale,
                DIMTIH   = this.dimtih,
                DIMTOH   = this.dimtoh,

                // text appearance
                DIMTXSTY = (TextStyle)this.dimtxsty.Clone(),
                DIMTXT   = this.dimtxt,
                DIMJUST  = this.dimjust,
                DIMTAD   = this.dimtad,
                DIMGAP   = this.dimgap,

                // primary units
                DIMADEC  = this.dimadec,
                DIMDEC   = this.dimdec,
                DIMPOST  = this.dimpost,
                DIMDSEP  = this.dimdsep,
                DIMAUNIT = this.dimaunit
            };

            if (this.dimblk != null)
            {
                copy.DIMBLK = (Block)this.dimblk.Clone();
            }
            if (this.dimblk1 != null)
            {
                copy.DIMBLK1 = (Block)this.dimblk1.Clone();
            }
            if (this.dimblk2 != null)
            {
                copy.DIMBLK2 = (Block)this.dimblk2.Clone();
            }

            return(copy);
        }
Exemple #20
0
        private static string FormatDimensionText(double measure, bool angular, string userText, DimensionStyle style, Layout layout)
        {
            if (userText == " ")
                return null;

            string text = string.Empty;

            UnitStyleFormat unitFormat = new UnitStyleFormat
            {
                LinearDecimalPlaces = style.LengthPrecision,
                AngularDecimalPlaces = style.AngularPrecision == -1 ? style.LengthPrecision : style.AngularPrecision,
                DecimalSeparator = style.DecimalSeparator.ToString(),
                FractionType = style.FractionalType,
                SupressLinearLeadingZeros = style.SuppressLinearLeadingZeros,
                SupressLinearTrailingZeros = style.SuppressLinearTrailingZeros,
                SupressAngularLeadingZeros = style.SuppressAngularLeadingZeros,
                SupressAngularTrailingZeros = style.SuppressAngularTrailingZeros,
                SupressZeroFeet = style.SuppressZeroFeet,
                SupressZeroInches = style.SuppressZeroInches
            };

            if (angular)
            {
                switch (style.DimAngularUnits)
                {
                    case AngleUnitType.DecimalDegrees:
                        text = AngleUnitFormat.ToDecimal(measure, unitFormat);
                        break;
                    case AngleUnitType.DegreesMinutesSeconds:
                        text = AngleUnitFormat.ToDegreesMinutesSeconds(measure, unitFormat);
                        break;
                    case AngleUnitType.Gradians:
                        text = AngleUnitFormat.ToGradians(measure, unitFormat);
                        break;
                    case AngleUnitType.Radians:
                        text = AngleUnitFormat.ToRadians(measure, unitFormat);
                        break;
                    case AngleUnitType.SurveyorUnits:
                        text = AngleUnitFormat.ToDecimal(measure, unitFormat);
                        break;
                }
            }
            else
            {
                double scale = Math.Abs(style.DimScaleLinear);
                if (layout != null)
                {
                    // if DIMLFAC is negative the scale value is only applied to dimensions in PaperSpace
                    if (style.DimScaleLinear < 0 && !layout.IsPaperSpace)
                        scale = 1.0;
                }

                if (style.DimRoundoff > 0.0)
                    measure = MathHelper.RoundToNearest(measure*scale, style.DimRoundoff);
                else
                    measure *= scale;

                switch (style.DimLengthUnits)
                {
                    case LinearUnitType.Architectural:
                        text = LinearUnitFormat.ToArchitectural(measure, unitFormat);
                        break;
                    case LinearUnitType.Decimal:
                        text = LinearUnitFormat.ToDecimal(measure, unitFormat);
                        break;
                    case LinearUnitType.Engineering:
                        text = LinearUnitFormat.ToEngineering(measure, unitFormat);
                        break;
                    case LinearUnitType.Fractional:
                        text = LinearUnitFormat.ToFractional(measure, unitFormat);
                        break;
                    case LinearUnitType.Scientific:
                        text = LinearUnitFormat.ToScientific(measure, unitFormat);
                        break;
                    case LinearUnitType.WindowsDesktop:
                        unitFormat.LinearDecimalPlaces = (short) Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalDigits;
                        unitFormat.DecimalSeparator = Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
                        text = LinearUnitFormat.ToDecimal(measure*style.DimScaleLinear, unitFormat);
                        break;
                }
            }
            text = string.Format("{0}{1}{2}", style.DimPrefix, text, style.DimSuffix);

            if (!string.IsNullOrEmpty(userText))
                text = userText.Replace("<>", text);

            return text;
        }
Exemple #21
0
 private static Line ExtensionLine(Vector2 start, Vector2 end, DimensionStyle style, Linetype linetype)
 {
     return new Line(start, end)
     {
         Color = style.ExtLineColor,
         Linetype = linetype,
         Lineweight = style.ExtLineLineweight
     };
 }
Exemple #22
0
        private static EntityObject EndArrowHead(Vector2 position, double rotation, DimensionStyle style)
        {
            Block block = style.DimArrow2;

            if (block == null)
            {
                Vector2 arrowRef = Vector2.Polar(position, -style.ArrowSize*style.DimScaleOverall, rotation);
                Solid arrow = new Solid(position,
                    Vector2.Polar(arrowRef, -(style.ArrowSize/6)*style.DimScaleOverall, rotation + MathHelper.HalfPI),
                    Vector2.Polar(arrowRef, (style.ArrowSize/6)*style.DimScaleOverall, rotation + MathHelper.HalfPI))
                {
                    Color = style.DimLineColor
                };
                return arrow;
            }
            else
            {
                Insert arrow = new Insert(block, position)
                {
                    Color = style.DimLineColor,
                    Scale = new Vector3(style.ArrowSize*style.DimScaleOverall),
                    Rotation = rotation*MathHelper.RadToDeg,
                    Lineweight = style.DimLineLineweight
                };
                return arrow;
            }
        }
Exemple #23
0
 /// <summary>
 /// Initializes a new instance of the <c>AlignedDimension</c> class.
 /// </summary>
 /// <param name="firstPoint">First reference <see cref="Vector2">point</see> of the dimension.</param>
 /// <param name="secondPoint">Second reference <see cref="Vector2">point</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The reference points define the distance to be measure.</remarks>
 public AlignedDimension(Vector2 firstPoint, Vector2 secondPoint, double offset, DimensionStyle style)
     : base(DimensionType.Aligned)
 {
     this.firstRefPoint = firstPoint;
     this.secondRefPoint = secondPoint;
     this.offset = offset;
     if (style == null)
         throw new ArgumentNullException(nameof(style));
     this.Style = style;
 }
Exemple #24
0
        /// <summary>
        /// Initializes a new instance of the <c>AlignedDimension</c> class.
        /// </summary>
        /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
        /// <param name="offset">Distance between the reference line and the dimension line.</param>
        /// <param name="normal">Normal vector of the plane where the dimension is defined.</param>
        /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
        /// <remarks>The reference line define the distance to be measure.</remarks>
        public AlignedDimension(Line referenceLine, double offset, Vector3 normal, DimensionStyle style)
            : base(DimensionType.Aligned)
        {
            if (referenceLine == null)
                throw new ArgumentNullException(nameof(referenceLine));

            Vector3 ocsPoint;
            ocsPoint = MathHelper.Transform(referenceLine.StartPoint, normal, CoordinateSystem.World, CoordinateSystem.Object);
            this.firstRefPoint = new Vector2(ocsPoint.X, ocsPoint.Y);
            ocsPoint = MathHelper.Transform(referenceLine.EndPoint, normal, CoordinateSystem.World, CoordinateSystem.Object);
            this.secondRefPoint = new Vector2(ocsPoint.X, ocsPoint.Y);
            this.offset = offset;
            if (style == null)
                throw new ArgumentNullException(nameof(style));
            this.Style = style;
            this.Normal = normal;
            this.Elevation = ocsPoint.Z;
        }
 /// <summary>
 /// Initializes a new instance of the <c>Angular2LineDimension</c> class.
 /// </summary>
 /// <param name="startFirstLine">Start <see cref="Vector2">point</see> of the first line that defines the angle to measure.</param>
 /// <param name="endFirstLine">End <see cref="Vector2">point</see> of the first line that defines the angle to measure.</param>
 /// <param name="startSecondLine">Start <see cref="Vector2">point</see> of the second line that defines the angle to measure.</param>
 /// <param name="endSecondLine">End <see cref="Vector2">point</see> of the second line that defines the angle to measure.</param>
 /// <param name="offset">Distance between the center point and the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 public Angular2LineDimension(Vector2 startFirstLine, Vector2 endFirstLine, Vector2 startSecondLine, Vector2 endSecondLine, double offset, DimensionStyle style)
     : this(new Vector3(startFirstLine.X, startFirstLine.Y, 0.0), new Vector3(endFirstLine.X, endFirstLine.Y, 0.0), new Vector3(startSecondLine.X, startSecondLine.Y, 0.0), new Vector3(endSecondLine.X, endSecondLine.Y, 0.0), offset, style)
 {
 }
Exemple #26
0
        /// <summary>
        /// Creates a new DimensionStyle that is a copy of the current instance.
        /// </summary>
        /// <param name="newName">DimensionStyle name of the copy.</param>
        /// <returns>A new DimensionStyle that is a copy of this instance.</returns>
        public override TableObject Clone(string newName)
        {
            DimensionStyle copy = new DimensionStyle(newName)
            {
                // dimension lines
                DimLineColor       = (AciColor)this.dimclrd.Clone(),
                DimLineLinetype    = (Linetype)this.dimltype.Clone(),
                DimLineLineweight  = this.dimlwd,
                DimLineOff         = this.dimsd,
                DimBaselineSpacing = this.dimdli,
                DimLineExtend      = this.dimdle,

                // extension lines
                ExtLineColor      = (AciColor)this.dimclre.Clone(),
                ExtLine1Linetype  = (Linetype)this.dimltex1.Clone(),
                ExtLine2Linetype  = (Linetype)this.dimltex2.Clone(),
                ExtLineLineweight = this.dimlwe,
                ExtLine1Off       = this.dimse1,
                ExtLine2Off       = this.dimse2,
                ExtLineOffset     = this.dimexo,
                ExtLineExtend     = this.dimexe,

                // symbols and arrows
                ArrowSize      = this.dimasz,
                CenterMarkSize = this.dimcen,
                //DIMSAH = this.dimsah,

                // fit
                DimScaleOverall = this.dimscale,
                DIMTIH          = this.dimtih,
                DIMTOH          = this.dimtoh,

                // text appearance
                TextStyle  = (TextStyle)this.dimtxsty.Clone(),
                TextColor  = (AciColor)this.dimclrt.Clone(),
                TextHeight = this.dimtxt,
                DIMJUST    = this.dimjust,
                DIMTAD     = this.dimtad,
                TextOffset = this.dimgap,

                // primary units
                AngularPrecision = this.dimadec,
                LengthPrecision  = this.dimdec,
                DimPrefix        = this.dimPrefix,
                DimSuffix        = this.dimSuffix,
                DecimalSeparator = this.dimdsep,
                DimAngularUnits  = this.dimaunit
            };

            if (this.dimldrblk != null)
            {
                copy.LeaderArrow = (Block)this.dimldrblk.Clone();
            }
            //if (this.dimblk != null) copy.DIMBLK = (Block) this.dimblk.Clone();
            if (this.dimblk1 != null)
            {
                copy.DimArrow1 = (Block)this.dimblk1.Clone();
            }
            if (this.dimblk2 != null)
            {
                copy.DimArrow2 = (Block)this.dimblk2.Clone();
            }

            return(copy);
        }
        /// <summary>
        /// Initializes a new instance of the <c>Angular2LineDimension</c> class.
        /// </summary>
        /// <param name="startFirstLine">Start <see cref="Vector2">point</see> of the first line that defines the angle to measure.</param>
        /// <param name="endFirstLine">End <see cref="Vector2">point</see> of the first line that defines the angle to measure.</param>
        /// <param name="startSecondLine">Start <see cref="Vector2">point</see> of the second line that defines the angle to measure.</param>
        /// <param name="endSecondLine">End <see cref="Vector2">point</see> of the second line that defines the angle to measure.</param>
        /// <param name="offset">Distance between the center point and the dimension line.</param>
        /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
        public Angular2LineDimension(Vector2 startFirstLine, Vector2 endFirstLine, Vector2 startSecondLine, Vector2 endSecondLine, double offset, DimensionStyle style)
            : base(DimensionType.Angular)
        {
            Vector2 dir1 = endFirstLine - startFirstLine;
            Vector2 dir2 = endSecondLine - startSecondLine;
            if (Vector2.AreParallel(dir1, dir2))
                throw new ArgumentException("The two lines that define the dimension are parallel.");

            this.startFirstLine = startFirstLine;
            this.endFirstLine = endFirstLine;
            this.startSecondLine = startSecondLine;
            this.endSecondLine = endSecondLine;

            if (MathHelper.IsZero(offset))
                throw new ArgumentOutOfRangeException(nameof(offset), "The offset value cannot be zero.");
            this.offset = offset;

            if (style == null)
                throw new ArgumentNullException(nameof(style));
            this.Style = style;
        }
Exemple #28
0
        /// <summary>
        /// Writes a new dimension style to the table section.
        /// </summary>
        /// <param name="dimStyle">DimensionStyle.</param>
        public void WriteDimensionStyle(DimensionStyle dimStyle)
        {
            if (this.activeTable != StringCode.DimensionStyleTable)
            {
                throw new InvalidDxfTableException(this.activeTable, this.file);
            }
            this.WriteCodePair(0, dimStyle.CodeName);
            this.WriteCodePair(105, dimStyle.Handle);

            this.WriteCodePair(100, SubclassMarker.TableRecord);

            this.WriteCodePair(100, SubclassMarker.DimensionStyle);

            this.WriteCodePair(2, dimStyle);

            // flags
            this.WriteCodePair(70, 0);
        }
        /// <summary>
        /// Initializes a new instance of the <c>Angular2LineDimension</c> class.
        /// </summary>
        /// <param name="firstLine">First <see cref="Line">line</see> that defines the angle to measure.</param>
        /// <param name="secondLine">Second <see cref="Line">line</see> that defines the angle to measure.</param>
        /// <param name="offset">Distance between the center point and the dimension line.</param>
        /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
        public Angular2LineDimension(Line firstLine, Line secondLine, double offset, Vector3 normal, DimensionStyle style)
            : base(DimensionType.Angular)
        {
            if (firstLine == null)
                throw new ArgumentNullException(nameof(firstLine));
            if (secondLine == null)
                throw new ArgumentNullException(nameof(secondLine));

            if (Vector3.AreParallel(firstLine.Direction, secondLine.Direction))
                throw new ArgumentException("The two lines that define the dimension are parallel.");

            IList<Vector3> ocsPoints =
                MathHelper.Transform(
                    new[]
                    {
                        firstLine.StartPoint,
                        firstLine.EndPoint,
                        secondLine.StartPoint,
                        secondLine.EndPoint
                    },
                    normal, CoordinateSystem.World, CoordinateSystem.Object);

            this.startFirstLine = new Vector2(ocsPoints[0].X, ocsPoints[0].Y);
            this.endFirstLine = new Vector2(ocsPoints[1].X, ocsPoints[1].Y);
            this.startSecondLine = new Vector2(ocsPoints[2].X, ocsPoints[2].Y);
            this.endSecondLine = new Vector2(ocsPoints[3].X, ocsPoints[3].Y);
            if (MathHelper.IsZero(offset))
                throw new ArgumentOutOfRangeException(nameof(offset), "The offset value cannot be zero.");
            this.offset = offset;

            if (style == null)
                throw new ArgumentNullException(nameof(style));
            this.Style = style;
            this.Normal = normal;
            this.Elevation = ocsPoints[0].Z;
        }
 /// <summary>
 /// Initializes a new instance of the <c>AlignedDimension</c> class.
 /// </summary>
 /// <param name="firstPoint">First reference <see cref="Vector2">point</see> of the dimension.</param>
 /// <param name="secondPoint">Second reference <see cref="Vector2">point</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The reference points define the distance to be measure.</remarks>
 public AlignedDimension(Vector2 firstPoint, Vector2 secondPoint, double offset, DimensionStyle style)
     : this(new Vector3(firstPoint.X, firstPoint.Y, 0.0), new Vector3(secondPoint.X, secondPoint.Y, 0.0), offset, style)
 {
 }
Exemple #31
0
 /// <summary>
 /// Initializes a new instance of the <c>AlignedDimension</c> class.
 /// </summary>
 /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The reference points define the distance to be measure.</remarks>
 public AlignedDimension(Line referenceLine, double offset, DimensionStyle style)
     : this(referenceLine, offset, Vector3.UnitZ, style)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <c>AlignedDimension</c> class.
 /// </summary>
 /// <param name="referenceLine">Reference <see cref="Line">line</see> of the dimension.</param>
 /// <param name="offset">Distance between the reference line and the dimension line.</param>
 /// <param name="style">The <see cref="DimensionStyle">style</see> to use with the dimension.</param>
 /// <remarks>The reference line define the distance to be measure.</remarks>
 public AlignedDimension(Line referenceLine, double offset, DimensionStyle style)
     : this(referenceLine.StartPoint, referenceLine.EndPoint, offset, style)
 {
     this.normal = referenceLine.Normal;
 }
Exemple #33
0
        /// <summary>
        /// Initializes a new instance of the <c>Tolerance</c> class.
        /// </summary>
        /// <param name="tolerance"></param>
        /// <param name="position"></param>
        public Tolerance(ToleranceEntry tolerance, Vector3 position)
            : base(EntityType.Tolerance, DxfObjectCode.Tolerance)
        {
            this.entry1 = tolerance;
            this.entry2 = null;
            this.height = string.Empty;
            this.showProjectedToleranceZoneSymbol = false;
            this.datumIdentifier = string.Empty;

            this.style = DimensionStyle.Default;
            this.position = position;
            this.rotation = 0.0;
        }
        private void WriteActiveDimensionStyleSystemVaribles(DimensionStyle style)
        {
            this.chunk.Write(9, "$DIMADEC");
            this.chunk.Write(70, style.DIMADEC);

            this.chunk.Write(9, "$DIMAUNIT");
            this.chunk.Write(70, (short)style.DIMAUNIT);

            this.chunk.Write(9, "$DIMASZ");
            this.chunk.Write(40, style.DIMASZ);

            short angSupress = 3;
            if (style.SuppressAngularLeadingZeros && style.SuppressAngularTrailingZeros)
                angSupress = 3;
            else if (!style.SuppressAngularLeadingZeros && !style.SuppressAngularTrailingZeros)
                angSupress = 0;
            else if (!style.SuppressAngularLeadingZeros && style.SuppressAngularTrailingZeros)
                angSupress = 2;
            else if (style.SuppressAngularLeadingZeros && !style.SuppressAngularTrailingZeros)
                angSupress = 1;
            this.chunk.Write(9, "$DIMAZIN");
            this.chunk.Write(70, angSupress);

            this.chunk.Write(9, "$DIMBLK");
            this.chunk.Write(1, style.DIMBLK == null ? "" : this.EncodeNonAsciiCharacters(style.DIMBLK.Name));

            this.chunk.Write(9, "$DIMBLK1");
            this.chunk.Write(1, style.DIMBLK1 == null ? "" : this.EncodeNonAsciiCharacters(style.DIMBLK1.Name));

            this.chunk.Write(9, "$DIMBLK2");
            this.chunk.Write(1, style.DIMBLK2 == null ? "" : this.EncodeNonAsciiCharacters(style.DIMBLK2.Name));

            this.chunk.Write(9, "$DIMLDRBLK");
            this.chunk.Write(1, style.DIMLDRBLK == null ? "" : this.EncodeNonAsciiCharacters(style.DIMLDRBLK.Name));

            this.chunk.Write(9, "$DIMCEN");
            this.chunk.Write(40, style.DIMCEN);

            this.chunk.Write(9, "$DIMCLRD");
            this.chunk.Write(70, style.DIMCLRD.Index);

            this.chunk.Write(9, "$DIMCLRE");
            this.chunk.Write(70, style.DIMCLRE.Index);

            this.chunk.Write(9, "$DIMCLRT");
            this.chunk.Write(70, style.DIMCLRT.Index);

            this.chunk.Write(9, "$DIMDEC");
            this.chunk.Write(70, style.DIMDEC);

            this.chunk.Write(9, "$DIMDLE");
            this.chunk.Write(40, style.DIMDLE);

            this.chunk.Write(9, "$DIMDLI");
            this.chunk.Write(40, style.DIMDLI);

            this.chunk.Write(9, "$DIMDSEP");
            this.chunk.Write(70, (short)style.DIMDSEP);

            this.chunk.Write(9, "$DIMEXE");
            this.chunk.Write(40, style.DIMEXE);

            this.chunk.Write(9, "$DIMEXO");
            this.chunk.Write(40, style.DIMEXO);

            this.chunk.Write(9, "$DIMGAP");
            this.chunk.Write(40, style.DIMGAP);

            this.chunk.Write(9, "$DIMJUST");
            this.chunk.Write(70, style.DIMJUST);

            this.chunk.Write(9, "$DIMLFAC");
            this.chunk.Write(40, style.DIMLFAC);

            this.chunk.Write(9, "$DIMLUNIT");
            this.chunk.Write(70, (short)style.DIMLUNIT);

            this.chunk.Write(9, "$DIMLWD");
            this.chunk.Write(70, style.DIMLWD.Value);

            this.chunk.Write(9, "$DIMLWE");
            this.chunk.Write(70, style.DIMLWE.Value);

            this.chunk.Write(9, "$DIMPOST");
            this.chunk.Write(1, this.EncodeNonAsciiCharacters(style.DIMPOST));

            this.chunk.Write(9, "$DIMRND");
            this.chunk.Write(40, style.DIMRND);

            this.chunk.Write(9, "$DIMSAH");
            if (style.DIMSAH)
                this.chunk.Write(70, (short)1);
            else
                this.chunk.Write(70, (short)0);

            this.chunk.Write(9, "$DIMSCALE");
            this.chunk.Write(40, style.DIMSCALE);

            this.chunk.Write(9, "$DIMSE1");
            if (style.DIMSE1)
                this.chunk.Write(70, (short)1);
            else
                this.chunk.Write(70, (short)0);

            this.chunk.Write(9, "$DIMSE2");
            if (style.DIMSE2)
                this.chunk.Write(70, (short)1);
            else
                this.chunk.Write(70, (short)0);

            this.chunk.Write(9, "$DIMTAD");
            this.chunk.Write(70, style.DIMTAD);

            this.chunk.Write(9, "$DIMTIH");
            this.chunk.Write(70, style.DIMTIH);

            this.chunk.Write(9, "$DIMTOH");
            this.chunk.Write(70, style.DIMTOH);

            this.chunk.Write(9, "$DIMTXT");
            this.chunk.Write(40, style.DIMTXT);

            short linSupress = 0;
            if (style.DIMLUNIT == LinearUnitType.Architectural || style.DIMLUNIT == LinearUnitType.Engineering)
            {
                if (style.SuppressZeroFeet && style.SuppressZeroFeet)
                    linSupress = 0;
                else if (!style.SuppressZeroFeet && !style.SuppressZeroFeet)
                    linSupress = 1;
                else if (!style.SuppressZeroFeet && style.SuppressZeroFeet)
                    linSupress = 2;
                else if (style.SuppressZeroFeet && !style.SuppressZeroFeet)
                    linSupress = 3;
            }

            if (!style.SuppressLinearLeadingZeros && !style.SuppressLinearTrailingZeros)
                linSupress += 0;
            else if (style.SuppressLinearLeadingZeros && !style.SuppressLinearTrailingZeros)
                linSupress += 4;
            else if (!style.SuppressLinearLeadingZeros && style.SuppressLinearTrailingZeros)
                linSupress += 8;
            else if (style.SuppressLinearLeadingZeros && style.SuppressLinearTrailingZeros)
                linSupress += 12;

            this.chunk.Write(9, "$DIMZIN");
            this.chunk.Write(70, linSupress);

            // CAUTION: The next four codes are not documented in the official dxf docs
            this.chunk.Write(9, "$DIMFRAC");
            this.chunk.Write(70, (short)style.DIMFRAC);

            this.chunk.Write(9, "$DIMLTYPE");
            this.chunk.Write(6, this.EncodeNonAsciiCharacters(style.DIMLTYPE.Name));

            this.chunk.Write(9, "$DIMLTEX1");
            this.chunk.Write(6, this.EncodeNonAsciiCharacters(style.DIMLTEX1.Name));

            this.chunk.Write(9, "$DIMLTEX2");
            this.chunk.Write(6, this.EncodeNonAsciiCharacters(style.DIMLTEX2.Name));            
        }