/// <summary>
        /// Creates a new OrdinateDimension that is a copy of the current instance.
        /// </summary>
        /// <returns>A new OrdinateDimension that is a copy of this instance.</returns>
        public override object Clone()
        {
            OrdinateDimension entity = new OrdinateDimension
            {
                //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,
                //OrdinateDimension properties
                Origin         = this.origin,
                ReferencePoint = this.referencePoint,
                Rotation       = this.rotation,
                Length         = this.length,
                Axis           = this.axis
            };

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

            return(entity);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new OrdinateDimension that is a copy of the current instance.
        /// </summary>
        /// <returns>A new OrdinateDimension that is a copy of this instance.</returns>
        public override object Clone()
        {
            OrdinateDimension entity = new OrdinateDimension
            {
                //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,
                UserText          = this.UserText,
                //OrdinateDimension properties
                Origin         = this.origin,
                ReferencePoint = this.referencePoint,
                Rotation       = this.rotation,
                Length         = this.length,
                Axis           = this.axis,
                Elevation      = this.Elevation
            };

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

            return(entity);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new OrdinateDimension that is a copy of the current instance.
        /// </summary>
        /// <returns>A new OrdinateDimension that is a copy of this instance.</returns>
        public override object Clone()
        {
            OrdinateDimension entity = new OrdinateDimension
            {
                //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.defPoint,
                TextReferencePoint      = this.TextReferencePoint,
                TextPositionManuallySet = this.TextPositionManuallySet,
                TextRotation            = this.TextRotation,
                AttachmentPoint         = this.AttachmentPoint,
                LineSpacingStyle        = this.LineSpacingStyle,
                LineSpacingFactor       = this.LineSpacingFactor,
                UserText                = this.UserText,
                Elevation               = this.Elevation,
                //OrdinateDimension properties
                FeaturePoint   = this.firstPoint,
                LeaderEndPoint = this.secondPoint,
                Rotation       = this.rotation,
                Axis           = this.axis
            };

            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);
        }
Ejemplo n.º 4
0
        public static Block Build(OrdinateDimension dim, string name)
        {
            DimensionStyle      style    = dim.Style;
            List <EntityObject> entities = new List <EntityObject>();

            double measure = dim.Measurement;

            dim.DefinitionPoint = dim.Origin;
            double angle = dim.Rotation * MathHelper.DegToRad;

            Vector3 localPoint = MathHelper.Transform(dim.Origin, dim.Normal, CoordinateSystem.World, CoordinateSystem.Object);
            Vector2 refCenter  = new Vector2(localPoint.X, localPoint.Y);

            double elev = localPoint.Z;

            Vector2 startPoint = refCenter + MathHelper.Transform(dim.ReferencePoint, angle, CoordinateSystem.Object, CoordinateSystem.World);

            dim.FirstPoint = MathHelper.Transform(new Vector3(startPoint.X, startPoint.Y, elev), dim.Normal, CoordinateSystem.Object, CoordinateSystem.World);

            if (dim.Axis == OrdinateDimensionAxis.X)
            {
                angle += MathHelper.HalfPI;
            }
            Vector2 endPoint = Vector2.Polar(startPoint, dim.Length, angle);

            dim.SecondPoint = MathHelper.Transform(new Vector3(endPoint.X, endPoint.Y, elev), dim.Normal, CoordinateSystem.Object, CoordinateSystem.World);

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

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

            short side = 1;

            if (dim.Length < 0)
            {
                side = -1;
            }

            // dimension lines
            entities.Add(new Line(Vector2.Polar(startPoint, side * style.DIMEXO * style.DIMSCALE, angle), endPoint));

            // dimension text
            Vector2 midText = Vector2.Polar(startPoint, dim.Length + side * style.DIMGAP * style.DIMSCALE, angle);

            dim.MidTextPoint = new Vector3(midText.X, midText.Y, elev); // this value is in OCS

            string text = FormatDimensionText(measure, false, dim.UserText, style, dim.Owner.Record.Layout);

            MText mText = DimensionText(midText, angle, text, style);

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

            // drawing block
            return(new Block(name, false, entities, null));
        }
Ejemplo n.º 5
0
        private void WriteOrdinateDimension(OrdinateDimension dim)
        {
            this.chunk.Write(100, SubclassMarker.OrdinateDimension);

            this.chunk.Write(13, dim.FirstPoint.X);
            this.chunk.Write(23, dim.FirstPoint.Y);
            this.chunk.Write(33, dim.FirstPoint.Z);

            this.chunk.Write(14, dim.SecondPoint.X);
            this.chunk.Write(24, dim.SecondPoint.Y);
            this.chunk.Write(34, dim.SecondPoint.Z);

            this.WriteXData(dim.XData);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new OrdinateDimension that is a copy of the current instance.
        /// </summary>
        /// <returns>A new OrdinateDimension that is a copy of this instance.</returns>
        public override object Clone()
        {
            OrdinateDimension entity = new OrdinateDimension
            {
                //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,
                //OrdinateDimension properties
                Origin = this.origin,
                ReferencePoint = this.referencePoint,
                Rotation = this.rotation,
                Length = this.length,
                Axis = this.axis,
                Elevation = this.Elevation
            };

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

            return entity;
        }
Ejemplo n.º 7
0
        public static Block Build(OrdinateDimension dim, string name)
        {
            DimensionStyle style = BuildDimensionStyleOverride(dim);
            List<EntityObject> entities = new List<EntityObject>();

            double measure = dim.Measurement;

            double angle = dim.Rotation*MathHelper.DegToRad;
            Vector2 refCenter = dim.Origin;

            Vector2 startPoint = refCenter + MathHelper.Transform(dim.ReferencePoint, angle, CoordinateSystem.Object, CoordinateSystem.World);

            if (dim.Axis == OrdinateDimensionAxis.X)
                angle += MathHelper.HalfPI;
            Vector2 endPoint = Vector2.Polar(startPoint, dim.Length, angle);

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

            short side = 1;
            if (dim.Length < 0)
                side = -1;

            // dimension lines
            entities.Add(new Line(Vector2.Polar(startPoint, side*style.ExtLineOffset*style.DimScaleOverall, angle), endPoint));

            // dimension text
            Vector2 midText = Vector2.Polar(startPoint, dim.Length + side*style.TextOffset*style.DimScaleOverall, angle);

            string text = FormatDimensionText(measure, false, dim.UserText, style, dim.Owner.Record.Layout);

            MText mText = DimensionText(midText, angle, text, style);
            if (mText != null)
            {
                mText.AttachmentPoint = side < 0 ? MTextAttachmentPoint.MiddleRight : MTextAttachmentPoint.MiddleLeft;
                entities.Add(mText);
            }

            IList<Vector3> wcsPoints = MathHelper.Transform(
                new[]
                {
                    new Vector3(startPoint.X, startPoint.Y, dim.Elevation),
                    new Vector3(endPoint.X, endPoint.Y, dim.Elevation),
                    new Vector3(dim.Origin.X, dim.Origin.Y, dim.Elevation)
                },
                dim.Normal, CoordinateSystem.Object, CoordinateSystem.World);
            dim.FirstPoint = wcsPoints[0];
            dim.SecondPoint = wcsPoints[1];
            dim.DefinitionPoint = wcsPoints[2];
            dim.MidTextPoint = new Vector3(midText.X, midText.Y, dim.Elevation); // this value is in OCS

            // drawing block
            return new Block(name, false, entities, null);
        }
Ejemplo n.º 8
0
        private OrdinateDimension ReadOrdinateDimension(Vector3 defPoint, OrdinateDimensionAxis axis, Vector3 normal, double rotation)
        {
            Vector3 firstPoint = Vector3.Zero;
            Vector3 secondPoint = Vector3.Zero;

            List<XData> xData = new List<XData>();

            while (this.chunk.Code != 0)
            {
                switch (this.chunk.Code)
                {
                    case 13:
                        firstPoint.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 23:
                        firstPoint.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 33:
                        firstPoint.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 14:
                        secondPoint.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 24:
                        secondPoint.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 34:
                        secondPoint.Z = this.chunk.ReadDouble();
                        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;
                }
            }
            Vector3 localPoint = MathHelper.Transform(defPoint, normal, CoordinateSystem.World, CoordinateSystem.Object);

            Vector2 refCenter = new Vector2(localPoint.X, localPoint.Y);

            localPoint = MathHelper.Transform(firstPoint, normal, CoordinateSystem.World, CoordinateSystem.Object);

            Vector2 firstRef = MathHelper.Transform(new Vector2(localPoint.X, localPoint.Y) - refCenter, rotation*MathHelper.DegToRad, CoordinateSystem.World, CoordinateSystem.Object);

            localPoint = MathHelper.Transform(secondPoint, normal, CoordinateSystem.World, CoordinateSystem.Object);
            Vector2 secondRef = MathHelper.Transform(new Vector2(localPoint.X, localPoint.Y) - refCenter, rotation*MathHelper.DegToRad, CoordinateSystem.World, CoordinateSystem.Object);

            double length = axis == OrdinateDimensionAxis.X ? secondRef.Y - firstRef.Y : secondRef.X - firstRef.X;

            OrdinateDimension entity = new OrdinateDimension
            {
                Origin = refCenter,
                ReferencePoint = firstRef,
                Length = length,
                Rotation = rotation,
                Axis = axis
            };

            entity.XData.AddRange(xData);

            return entity;
        }
Ejemplo n.º 9
0
        public static Block Build(OrdinateDimension dim, string name)
        {
            DimensionStyle style = dim.Style;
            List<EntityObject> entities = new List<EntityObject>();

            double measure = dim.Measurement;

            dim.DefinitionPoint = dim.Origin;
            double angle = dim.Rotation * MathHelper.DegToRad;

            Vector3 localPoint = MathHelper.Transform(dim.Origin, dim.Normal, MathHelper.CoordinateSystem.World, MathHelper.CoordinateSystem.Object);
            Vector2 refCenter = new Vector2(localPoint.X, localPoint.Y);

            double elev = localPoint.Z;

            Vector2 startPoint = refCenter + MathHelper.Transform(dim.ReferencePoint, angle, MathHelper.CoordinateSystem.Object, MathHelper.CoordinateSystem.World);
            dim.FirstPoint = MathHelper.Transform(new Vector3(startPoint.X, startPoint.Y, elev), dim.Normal, MathHelper.CoordinateSystem.Object, MathHelper.CoordinateSystem.World);

            if (dim.Axis == OrdinateDimensionAxis.X)
                angle += MathHelper.HalfPI;
            Vector2 endPoint = Vector2.Polar(startPoint, dim.Length, angle);
            dim.SecondPoint = MathHelper.Transform(new Vector3(endPoint.X, endPoint.Y, elev), dim.Normal, MathHelper.CoordinateSystem.Object, MathHelper.CoordinateSystem.World);

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

            short side = 1;
            if (dim.Length < 0) side = -1;

            // dimension lines
            entities.Add(new Line(Vector2.Polar(startPoint, style.DIMEXO * style.DIMSCALE, angle), endPoint));

            // dimension text
            Vector2 midText = Vector2.Polar(startPoint, dim.Length + side * style.DIMGAP * style.DIMSCALE, angle);
            dim.MidTextPoint = new Vector3(midText.X, midText.Y, elev); // this value is in OCS

            string text = FormatDimensionText(measure, false, dim.UserText, style, dim.Owner.Record.Layout);

            MText mText = DimensionText(midText, angle, text, style);
            if (mText != null)
            {
                mText.AttachmentPoint = side<0 ? MTextAttachmentPoint.MiddleRight : MTextAttachmentPoint.MiddleLeft;
                entities.Add(mText);
            }

            // drawing block
            return new Block(name, false, entities, null);
        }
Ejemplo n.º 10
0
        private static void OrdinateDimensionDrawing()
        {
            DxfDocument dxf = new DxfDocument();

            Vector3 origin = new Vector3(2, 1, 0);
            Vector2 refX = new Vector2(1, 0);
            Vector2 refY = new Vector2(0, 2);
            double length = 3;
            double angle = 30;
            DimensionStyle myStyle = new DimensionStyle("MyStyle");
            myStyle.DIMPOST = "<>mm";
            myStyle.DIMDEC = 2;

            OrdinateDimension dimX1 = new OrdinateDimension(origin, refX, length, OrdinateDimensionAxis.X, 0, myStyle);
            OrdinateDimension dimX2 = new OrdinateDimension(origin, refX, length, OrdinateDimensionAxis.X, angle, myStyle);
            OrdinateDimension dimY1 = new OrdinateDimension(origin, refY, length, OrdinateDimensionAxis.Y, 0, myStyle);
            OrdinateDimension dimY2 = new OrdinateDimension(origin, refY, length, OrdinateDimensionAxis.Y, angle, myStyle);

            dxf.AddEntity(dimX1);
            dxf.AddEntity(dimY1);
            dxf.AddEntity(dimX2);
            dxf.AddEntity(dimY2);

            Line lineX = new Line(origin, origin+5 * Vector3.UnitX);
            Line lineY = new Line(origin, origin+5 * Vector3.UnitY);

            Vector2 point = Vector2.Polar(new Vector2(origin.X, origin.Y), 5, angle * MathHelper.DegToRad);
            Line lineXRotate = new Line(origin, new Vector3(point.X, point.Y, 0));

            point = Vector2.Polar(new Vector2(origin.X, origin.Y), 5, angle * MathHelper.DegToRad + MathHelper.HalfPI);
            Line lineYRotate = new Line(origin, new Vector3(point.X, point.Y, 0));

            dxf.AddEntity(lineX);
            dxf.AddEntity(lineY);
            dxf.AddEntity(lineXRotate);
            dxf.AddEntity(lineYRotate);

            dxf.Save("ordinate dimension.dxf");

            dxf = DxfDocument.Load("ordinate dimension.dxf");
        }
Ejemplo n.º 11
0
        private static void OrdinateDimension()
        {
            DxfDocument dxf = new DxfDocument();

            Vector3 origin = new Vector3(2, 1, 0);
            Vector2 refX = new Vector2(1, 0);
            Vector2 refY = new Vector2(0, 2);
            double length = 3;
            double angle = 30;
            DimensionStyle myStyle = CreateDimStyle();

            OrdinateDimension dimX1 = new OrdinateDimension(origin, refX, length, OrdinateDimensionAxis.X, 0, myStyle);
            OrdinateDimension dimX2 = new OrdinateDimension(origin, refX, length, OrdinateDimensionAxis.X, angle, myStyle);
            OrdinateDimension dimY1 = new OrdinateDimension(origin, refY, length, OrdinateDimensionAxis.Y, 0, myStyle);
            OrdinateDimension dimY2 = new OrdinateDimension(origin, refY, length, OrdinateDimensionAxis.Y, angle, myStyle);

            dxf.AddEntity(dimX1);
            dxf.AddEntity(dimY1);
            dxf.AddEntity(dimX2);
            dxf.AddEntity(dimY2);

            Line lineX = new Line(origin, origin + 5 * Vector3.UnitX);
            Line lineY = new Line(origin, origin + 5 * Vector3.UnitY);

            Vector2 point = Vector2.Polar(new Vector2(origin.X, origin.Y), 5, angle * MathHelper.DegToRad);
            Line lineXRotate = new Line(origin, new Vector3(point.X, point.Y, 0));

            point = Vector2.Polar(new Vector2(origin.X, origin.Y), 5, angle * MathHelper.DegToRad + MathHelper.HalfPI);
            Line lineYRotate = new Line(origin, new Vector3(point.X, point.Y, 0));

            dxf.AddEntity(lineX);
            dxf.AddEntity(lineY);
            dxf.AddEntity(lineXRotate);
            dxf.AddEntity(lineYRotate);

            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");
        }