/// <summary>
        /// Creates a new RadialDimension that is a copy of the current instance.
        /// </summary>
        /// <returns>A new RadialDimension that is a copy of this instance.</returns>
        public override object Clone()
        {
            RadialDimension entity = new RadialDimension
            {
                //EntityObject properties
                Layer         = (Layer)this.Layer.Clone(),
                Linetype      = (Linetype)this.Linetype.Clone(),
                Color         = (AciColor)this.Color.Clone(),
                Lineweight    = this.Lineweight,
                Transparency  = (Transparency)this.Transparency.Clone(),
                LinetypeScale = this.LinetypeScale,
                Normal        = this.Normal,
                IsVisible     = this.IsVisible,
                //Dimension properties
                Style             = (DimensionStyle)this.Style.Clone(),
                AttachmentPoint   = this.AttachmentPoint,
                LineSpacingStyle  = this.LineSpacingStyle,
                LineSpacingFactor = this.LineSpacingFactor,
                //RadialDimension properties
                CenterPoint    = this.center,
                ReferencePoint = this.refPoint,
                Offset         = this.offset,
                Elevation      = this.Elevation
            };

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

            return(entity);
        }
Example #2
0
        /// <summary>
        /// Creates a new RadialDimension that is a copy of the current instance.
        /// </summary>
        /// <returns>A new RadialDimension that is a copy of this instance.</returns>
        public override object Clone()
        {
            RadialDimension entity = new RadialDimension
            {
                //EntityObject properties
                Layer = (Layer)this.layer.Clone(),
                LineType = (LineType)this.lineType.Clone(),
                Color = (AciColor)this.color.Clone(),
                Lineweight = (Lineweight)this.lineweight.Clone(),
                Transparency = (Transparency)this.transparency.Clone(),
                LineTypeScale = this.lineTypeScale,
                Normal = this.normal,
                //Dimension properties
                Style = this.style,
                AttachmentPoint = this.attachmentPoint,
                LineSpacingStyle = this.lineSpacingStyle,
                LineSpacingFactor = this.lineSpacing,
                //RadialDimension properties
                CenterPoint = this.definitionPoint,
                Radius = this.radius,
                Rotation = this.rotation
            };

            foreach (XData data in this.XData.Values)
                entity.XData.Add((XData)data.Clone());

            return entity;

        }
Example #3
0
        /// <summary>
        /// Creates a new RadialDimension that is a copy of the current instance.
        /// </summary>
        /// <returns>A new RadialDimension that is a copy of this instance.</returns>
        public override object Clone()
        {
            RadialDimension entity = new RadialDimension
            {
                //EntityObject properties
                Layer         = (Layer)this.Layer.Clone(),
                Linetype      = (Linetype)this.Linetype.Clone(),
                Color         = (AciColor)this.Color.Clone(),
                Lineweight    = this.Lineweight,
                Transparency  = (Transparency)this.Transparency.Clone(),
                LinetypeScale = this.LinetypeScale,
                Normal        = this.Normal,
                IsVisible     = this.IsVisible,
                //Dimension properties
                Style                   = (DimensionStyle)this.Style.Clone(),
                DefinitionPoint         = this.DefinitionPoint,
                TextReferencePoint      = this.TextReferencePoint,
                TextPositionManuallySet = this.TextPositionManuallySet,
                TextRotation            = this.TextRotation,
                AttachmentPoint         = this.AttachmentPoint,
                LineSpacingStyle        = this.LineSpacingStyle,
                LineSpacingFactor       = this.LineSpacingFactor,
                UserText                = this.UserText,
                Elevation               = this.Elevation,
                //RadialDimension properties
                CenterPoint    = this.center,
                ReferencePoint = this.refPoint
            };

            foreach (DimensionStyleOverride styleOverride in this.StyleOverrides.Values)
            {
                object     copy;
                ICloneable value = styleOverride.Value as ICloneable;
                copy = value != null?value.Clone() : styleOverride.Value;

                entity.StyleOverrides.Add(new DimensionStyleOverride(styleOverride.Type, copy));
            }

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

            return(entity);
        }
        public static Block Build(RadialDimension dim, string name)
        {
            double              offset   = dim.Offset;
            double              measure  = dim.Measurement;
            DimensionStyle      style    = dim.Style;
            List <EntityObject> entities = new List <EntityObject>();

            // we will build the dimension block in object coordinates with normal the dimension normal
            Vector3 refPoint;

            refPoint = MathHelper.Transform(dim.CenterPoint, dim.Normal, CoordinateSystem.World, CoordinateSystem.Object);

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

            refPoint = MathHelper.Transform(dim.ReferencePoint, dim.Normal, CoordinateSystem.World, CoordinateSystem.Object);
            Vector2 ref1 = new Vector2(refPoint.X, refPoint.Y);

            double  angleRef = Vector2.Angle(centerRef, ref1);
            Vector2 ref2     = Vector2.Polar(ref1, -measure, angleRef);

            short reverse = 1;

            if (angleRef > MathHelper.HalfPI && angleRef <= MathHelper.ThreeHalfPI)
            {
                reverse = -1;
            }

            short  side;
            double minOffset = 2 * style.DIMASZ + style.DIMGAP * style.DIMSCALE;

            if (offset >= measure && offset <= measure + minOffset)
            {
                offset = measure + minOffset;
                side   = -1;
            }
            else if (offset >= measure - minOffset && offset <= measure)
            {
                offset = measure - minOffset;
                side   = 1;
            }
            else if (offset > measure)
            {
                side = -1;
            }
            else
            {
                side = 1;
            }

            Vector2 dimRef = Vector2.Polar(centerRef, offset, angleRef);

            // reference points
            Layer defPoints = new Layer("Defpoints")
            {
                Plot = false
            };

            entities.Add(new Point(ref1)
            {
                Layer = defPoints
            });

            // dimension lines
            entities.Add(DimensionRadialLine(dimRef, ref1, angleRef, side, style));

            // center cross
            entities.AddRange(CenterCross(centerRef, measure, style));

            // dimension arrows
            entities.Add(EndArrowHead(ref1, (1 - side) * MathHelper.HalfPI + angleRef, style));

            // dimension text
            string text = "R" + FormatDimensionText(measure, false, dim.UserText, style, dim.Owner.Record.Layout);

            double textRot = angleRef;

            if (textRot > MathHelper.HalfPI && textRot <= MathHelper.ThreeHalfPI)
            {
                textRot += MathHelper.PI;
            }

            MText mText = DimensionText(Vector2.Polar(dimRef, -reverse * side * style.DIMGAP * style.DIMSCALE, textRot), textRot, text, style);

            if (mText != null)
            {
                mText.AttachmentPoint = reverse * side < 0 ? MTextAttachmentPoint.MiddleLeft : MTextAttachmentPoint.MiddleRight;
                entities.Add(mText);
            }

            dim.DefinitionPoint = MathHelper.Transform(new Vector3(ref2.X, ref2.Y, elev), dim.Normal, CoordinateSystem.Object, CoordinateSystem.World);
            dim.MidTextPoint    = new Vector3(dimRef.X, dimRef.Y, elev); // this value is in OCS

            return(new Block(name, false, entities, null));
        }
Example #5
0
        /// <summary>
        /// Creates a new RadialDimension that is a copy of the current instance.
        /// </summary>
        /// <returns>A new RadialDimension that is a copy of this instance.</returns>
        public override object Clone()
        {
            RadialDimension entity = new RadialDimension
            {
                //EntityObject properties
                Layer = (Layer)this.layer.Clone(),
                LineType = (LineType)this.lineType.Clone(),
                Color = (AciColor)this.color.Clone(),
                Lineweight = (Lineweight)this.lineweight.Clone(),
                Transparency = (Transparency)this.transparency.Clone(),
                LineTypeScale = this.lineTypeScale,
                Normal = this.normal,
                //Dimension properties
                Style = (DimensionStyle)this.style.Clone(),
                AttachmentPoint = this.attachmentPoint,
                LineSpacingStyle = this.lineSpacingStyle,
                LineSpacingFactor = this.lineSpacing,
                //RadialDimension properties
                CenterPoint = this.definitionPoint,
                ReferencePoint = this.refPoint,
                Offset = this.offset
            };

            foreach (XData data in this.XData.Values)
                entity.XData.Add((XData)data.Clone());

            return entity;

        }
        private void WriteRadialDimension(RadialDimension dim)
        {
            this.chunk.Write(100, SubclassMarker.RadialDimension);

            this.chunk.Write(15, dim.ReferencePoint.X);
            this.chunk.Write(25, dim.ReferencePoint.Y);
            this.chunk.Write(35, dim.ReferencePoint.Z);

            this.chunk.Write(40, 0.0);

            this.WriteXData(dim.XData);
        }
Example #7
0
        public static Block Build(RadialDimension dim, string name)
        {
            double offset = dim.Offset;
            double measure = dim.Measurement;
            DimensionStyle style = BuildDimensionStyleOverride(dim);
            List<EntityObject> entities = new List<EntityObject>();

            Vector2 centerRef = dim.CenterPoint;
            Vector2 ref1 = dim.ReferencePoint;

            double angleRef = Vector2.Angle(centerRef, ref1);

            short side;
            double minOffset = 2*style.ArrowSize + style.TextOffset*style.DimScaleOverall;
            if (offset >= measure && offset <= measure + minOffset)
            {
                offset = measure + minOffset;
                side = -1;
            }
            else if (offset >= measure - minOffset && offset <= measure)
            {
                offset = measure - minOffset;
                side = 1;
            }
            else if (offset > measure)
                side = -1;
            else
                side = 1;

            Vector2 dimRef = Vector2.Polar(centerRef, offset, angleRef);

            // reference points
            Layer defPoints = new Layer("Defpoints") {Plot = false};
            entities.Add(new Point(ref1) {Layer = defPoints});

            // dimension lines
            entities.Add(DimensionRadialLine(dimRef, ref1, angleRef, side, style));

            // center cross
            entities.AddRange(CenterCross(centerRef, measure, style));

            // dimension arrows
            entities.Add(EndArrowHead(ref1, (1 - side)*MathHelper.HalfPI + angleRef, style));

            // dimension text
            string text = "R" + FormatDimensionText(measure, false, dim.UserText, style, dim.Owner.Record.Layout);

            double textRot = angleRef;
            short reverse = 1;
            if (angleRef > MathHelper.HalfPI && angleRef <= MathHelper.ThreeHalfPI)
            {
                textRot += MathHelper.PI;
                reverse = -1;
            }

            MText mText = DimensionText(Vector2.Polar(dimRef, -reverse*side*style.TextOffset*style.DimScaleOverall, textRot), textRot, text, style);
            if (mText != null)
            {
                mText.AttachmentPoint = reverse*side < 0 ? MTextAttachmentPoint.MiddleLeft : MTextAttachmentPoint.MiddleRight;
                entities.Add(mText);
            }

            dim.DefinitionPoint = MathHelper.Transform(new Vector3(centerRef.X, centerRef.Y, dim.Elevation), dim.Normal, CoordinateSystem.Object, CoordinateSystem.World);
            dim.MidTextPoint = new Vector3(dimRef.X, dimRef.Y, dim.Elevation); // this value is in OCS

            return new Block(name, false, entities, null);
        }
Example #8
0
        private void WriteRadialDimension(RadialDimension dim)
        {
            this.chunk.Write(100, SubclassMarker.RadialDimension);

            Vector3 wcsPoint = MathHelper.Transform(new Vector3(dim.ReferencePoint.X, dim.ReferencePoint.Y, dim.Elevation), dim.Normal, CoordinateSystem.Object, CoordinateSystem.World);
            this.chunk.Write(15, wcsPoint.X);
            this.chunk.Write(25, wcsPoint.Y);
            this.chunk.Write(35, wcsPoint.Z);

            this.chunk.Write(40, 0.0);

            this.WriteXData(dim.XData);
        }
Example #9
0
        private RadialDimension ReadRadialDimension(Vector3 defPoint, Vector3 midtxtPoint, Vector3 normal)
        {
            Vector3 circunferenceRef = Vector3.Zero;
            List<XData> xData = new List<XData>();

            while (this.chunk.Code != 0)
            {
                switch (this.chunk.Code)
                {
                    case 15:
                        circunferenceRef.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 25:
                        circunferenceRef.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 35:
                        circunferenceRef.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 40:
                        this.chunk.Next();
                        break;
                    case 1001:
                        string appId = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        XData data = this.ReadXDataRecord(this.GetApplicationRegistry(appId));
                        xData.Add(data);
                        break;
                    default:
                        if (this.chunk.Code >= 1000 && this.chunk.Code <= 1071)
                            throw new Exception("The extended data of an entity must start with the application registry code.");
                        this.chunk.Next();
                        break;
                }
            }

            IList<Vector3> ocsPoints = MathHelper.Transform(
                new List<Vector3>
                {
                    circunferenceRef, defPoint
                },
                normal, CoordinateSystem.World, CoordinateSystem.Object);

            double offset = Vector3.Distance(defPoint, midtxtPoint);
            RadialDimension entity = new RadialDimension
            {
                CenterPoint = new Vector2(ocsPoints[1].X, ocsPoints[1].Y),
                ReferencePoint = new Vector2(ocsPoints[0].X, ocsPoints[0].Y),
                Elevation = ocsPoints[1].Z,
                Normal = normal,
                Offset = offset
            };

            entity.XData.AddRange(xData);

            return entity;
        }
Example #10
0
        public static Block Build(RadialDimension dim, string name)
        {
            double offset = dim.Offset;
            double measure = dim.Measurement;
            DimensionStyle style = dim.Style;
            List<EntityObject> entities = new List<EntityObject>();

            // we will build the dimension block in object coordinates with normal the dimension normal
            Vector3 refPoint;

            refPoint = MathHelper.Transform(dim.CenterPoint, dim.Normal, MathHelper.CoordinateSystem.World, MathHelper.CoordinateSystem.Object);

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

            refPoint = MathHelper.Transform(dim.ReferencePoint, dim.Normal, MathHelper.CoordinateSystem.World, MathHelper.CoordinateSystem.Object);
            Vector2 ref1 = new Vector2(refPoint.X, refPoint.Y);

            double angleRef = Vector2.Angle(centerRef, ref1);
            Vector2 ref2 = Vector2.Polar(ref1, -measure, angleRef);

            short reverse = 1;
            if (angleRef > MathHelper.HalfPI && angleRef <= MathHelper.ThreeHalfPI)
                reverse = -1;

            short side = 1;
            double minOffset = 2 * style.DIMASZ + style.DIMGAP * style.DIMSCALE;
            if (offset > (measure - minOffset) && offset < measure)
            {
                offset = measure - minOffset;
                side = 1;
            }
            else if (offset >= measure && offset < (measure + minOffset))
            {
                offset = measure + minOffset;
                side = -1;
            }

            Vector2 dimRef = Vector2.Polar(centerRef, offset, angleRef);

            // reference points
            Layer defPoints = new Layer("Defpoints") { Plot = false };
            entities.Add(new Point(ref1) { Layer = defPoints });

            // dimension lines
            entities.Add(DimensionRadialLine(dimRef, ref1, angleRef, side, style));

            // center cross
            entities.AddRange(CenterCross(centerRef, measure, style));

            // dimension arrows
            entities.Add(EndArrowHead(ref1, (1 - side) * MathHelper.HalfPI + angleRef, style));

            // dimension text
            string text = "R" + FormatDimensionText(measure, false, dim.UserText, style, dim.Owner.Record.Layout);

            double textRot = angleRef;
            if (textRot > MathHelper.HalfPI && textRot <= MathHelper.ThreeHalfPI)
                textRot += MathHelper.PI;

            MText mText = DimensionText(Vector2.Polar(dimRef, -reverse * side * style.DIMGAP * style.DIMSCALE, textRot), textRot, text, style);
            if (mText != null)
            {
                mText.AttachmentPoint = reverse * side < 0 ? MTextAttachmentPoint.MiddleLeft : MTextAttachmentPoint.MiddleRight;
                entities.Add(mText);
            }

            dim.DefinitionPoint = MathHelper.Transform(new Vector3(ref2.X, ref2.Y, elev), dim.Normal, MathHelper.CoordinateSystem.Object, MathHelper.CoordinateSystem.World);
            dim.MidTextPoint = new Vector3(dimRef.X, dimRef.Y, elev); // this value is in OCS

            return new Block(name, false, entities, null);
            
        }
Example #11
0
        /// <summary>
        /// Creates a new RadialDimension that is a copy of the current instance.
        /// </summary>
        /// <returns>A new RadialDimension that is a copy of this instance.</returns>
        public override object Clone()
        {
            RadialDimension entity = new RadialDimension
            {
                //EntityObject properties
                Layer = (Layer) this.Layer.Clone(),
                Linetype = (Linetype) this.Linetype.Clone(),
                Color = (AciColor) this.Color.Clone(),
                Lineweight = this.Lineweight,
                Transparency = (Transparency) this.Transparency.Clone(),
                LinetypeScale = this.LinetypeScale,
                Normal = this.Normal,
                IsVisible = this.IsVisible,
                //Dimension properties
                Style = (DimensionStyle) this.Style.Clone(),
                AttachmentPoint = this.AttachmentPoint,
                LineSpacingStyle = this.LineSpacingStyle,
                LineSpacingFactor = this.LineSpacingFactor,
                //RadialDimension properties
                CenterPoint = this.center,
                ReferencePoint = this.refPoint,
                Offset = this.offset,
                Elevation = this.Elevation
            };

            foreach (XData data in this.XData.Values)
                entity.XData.Add((XData) data.Clone());

            return entity;
        }
Example #12
0
        private static void RadialDimension()
        {
            DxfDocument dxf = new DxfDocument();
            DimensionStyle myStyle = CreateDimStyle();

            Vector3 center = new Vector3(1, 2, 0);
            double radius = 3;
            Circle circle = new Circle(center, radius);
            //circle.Normal = new Vector3(1, 1, 1);
            double angle = MathHelper.HalfPI * 0.5;
            Vector3 refPoint = center + new Vector3(radius * Math.Cos(angle), radius * Math.Cos(angle), 0);

            //DiametricDimension dim = new DiametricDimension(center, refPoint, -1.0, myStyle);
            double offset = 3;
            RadialDimension dim1 = new RadialDimension(circle, 0, offset, myStyle);
            RadialDimension dim2 = new RadialDimension(circle, 45, offset, myStyle);
            RadialDimension dim3 = new RadialDimension(circle, 90, offset, myStyle);
            RadialDimension dim4 = new RadialDimension(circle, 120, offset, myStyle);
            RadialDimension dim5 = new RadialDimension(circle, 180, offset, myStyle);
            RadialDimension dim6 = new RadialDimension(circle, 220, offset, myStyle);
            RadialDimension dim7 = new RadialDimension(circle, 270, offset, myStyle);
            RadialDimension dim8 = new RadialDimension(circle, 330, offset, myStyle);
            // if the dimension normal is not equal to the circle normal strange things might happen at the moment
            //dim1.Normal = circle.Normal;
            dxf.AddEntity(circle);
            dxf.AddEntity(dim1);
            dxf.AddEntity(dim2);
            dxf.AddEntity(dim3);
            dxf.AddEntity(dim4);
            dxf.AddEntity(dim5);
            dxf.AddEntity(dim6);
            dxf.AddEntity(dim7);
            dxf.AddEntity(dim8);
            dxf.Save("dimension drawing.dxf");

            dxf = DxfDocument.Load("dimension drawing.dxf");

            DxfDocument doc = new DxfDocument();
            foreach (var c in dxf.Circles)
            {
                doc.AddEntity((EntityObject)c.Clone());
            }
            foreach (var d in dxf.Dimensions)
            {
                doc.AddEntity((EntityObject)d.Clone());
            }
            doc.Save("dimension drawing saved.dxf");
        }
Example #13
0
        private RadialDimension ReadRadialDimension(Vector3 defPoint)
        {
            Vector3 circunferenceRef = Vector3.Zero;
            List<XData> xData = new List<XData>();

            while (this.chunk.Code != 0)
            {
                switch (this.chunk.Code)
                {
                    case 15:
                        circunferenceRef.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 25:
                        circunferenceRef.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 35:
                        circunferenceRef.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 40:
                        this.chunk.Next();
                        break;
                    case 1001:
                        string appId = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        XData data = this.ReadXDataRecord(appId);
                        xData.Add(data);
                        break;
                    default:
                        if (this.chunk.Code >= 1000 && this.chunk.Code <= 1071)
                            throw new DxfInvalidCodeValueEntityException(this.chunk.Code, this.chunk.ReadString(),
                                "The extended data of an entity must start with the application registry code.");
                        this.chunk.Next();
                        break;
                }
            }

            RadialDimension entity = new RadialDimension
            {
                CenterPoint = Vector3.MidPoint(defPoint, circunferenceRef),
                ReferencePoint = circunferenceRef
            };

            entity.XData.AddRange(xData);

            return entity;
        }
Example #14
0
        private static void RadialDimension()
        {
            Font f = new Font("Arial",16);
            string text = "3.6669";

            Bitmap fakeImage = new Bitmap(1, 1);
            fakeImage.SetResolution(96, 96);
            Graphics g = Graphics.FromImage(fakeImage);

            Size size = TextRenderer.MeasureText(text, f);
           
            SizeF sizeF = g.MeasureString(text, f, new PointF(100,0), StringFormat.GenericTypographic);


            DxfDocument dxf = new DxfDocument();
            DimensionStyle myStyle = CreateDimStyle();

            Vector3 center = new Vector3(1, 2, 0);
            double radius = 3;
            Circle circle = new Circle(center, radius);
            //circle.Normal = new Vector3(1, 1, 1);
            double angle = MathHelper.HalfPI * 0.5;
            Vector3 refPoint = center + new Vector3(radius * Math.Cos(angle), radius * Math.Cos(angle), 0);


            //DiametricDimension dim = new DiametricDimension(center, refPoint, -1.0, myStyle);
            double offset = radius;
            RadialDimension dim1 = new RadialDimension(circle, 0, offset, myStyle);
            RadialDimension dim2 = new RadialDimension(circle, 45, offset, myStyle);
            RadialDimension dim3 = new RadialDimension(circle, 90, offset, myStyle);
            RadialDimension dim4 = new RadialDimension(circle, 120, offset, myStyle);
            RadialDimension dim5 = new RadialDimension(circle, 180, offset, myStyle);
            RadialDimension dim6 = new RadialDimension(circle, 220, offset, myStyle);
            RadialDimension dim7 = new RadialDimension(circle, 270, offset, myStyle);
            RadialDimension dim8 = new RadialDimension(circle, 330, offset, myStyle);
            // if the dimension normal is not equal to the circle normal strange things might happen at the moment
            //dim1.Normal = circle.Normal;
            dxf.AddEntity(circle);
            //dxf.AddEntity(dim1);
            //dxf.AddEntity(dim2);
            //dxf.AddEntity(dim3);
            //dxf.AddEntity(dim4);
            //dxf.AddEntity(dim5);
            //dxf.AddEntity(dim6);
            //dxf.AddEntity(dim7);
            //dxf.AddEntity(dim8);
            dxf.Save("dimension drawing.dxf");

            dxf = DxfDocument.Load("dimension drawing.dxf");

            DxfDocument doc = new DxfDocument();
            foreach (var c in dxf.Circles)
            {
                doc.AddEntity((EntityObject)c.Clone());
            }
            foreach (var d in dxf.Dimensions)
            {
                doc.AddEntity((EntityObject)d.Clone());
            }
            doc.Save("dimension drawing saved.dxf");
        }