コード例 #1
0
        private void WriteSolid(Solid solid)
        {
            this.chunk.Write(100, SubclassMarker.Solid);

            // the vertexes are stored in OCS
            this.chunk.Write(10, solid.FirstVertex.X);
            this.chunk.Write(20, solid.FirstVertex.Y);
            this.chunk.Write(30, solid.Elevation);

            this.chunk.Write(11, solid.SecondVertex.X);
            this.chunk.Write(21, solid.SecondVertex.Y);
            this.chunk.Write(31, solid.Elevation);

            this.chunk.Write(12, solid.ThirdVertex.X);
            this.chunk.Write(22, solid.ThirdVertex.Y);
            this.chunk.Write(32, solid.Elevation);

            this.chunk.Write(13, solid.FourthVertex.X);
            this.chunk.Write(23, solid.FourthVertex.Y);
            this.chunk.Write(33, solid.Elevation);

            this.chunk.Write(39, solid.Thickness);

            this.chunk.Write(210, solid.Normal.X);
            this.chunk.Write(220, solid.Normal.Y);
            this.chunk.Write(230, solid.Normal.Z);

            this.WriteXData(solid.XData);
        }
コード例 #2
0
ファイル: Reader.cs プロジェクト: steve-stanton/backsight
        private Solid ReadSolid(ref CodeValuePair code)
        {
            var solid = new Solid();
            Vector3d v0 = Vector3d.Zero;
            Vector3d v1 = Vector3d.Zero;
            Vector3d v2 = Vector3d.Zero;
            Vector3d v3 = Vector3d.Zero;
            Vector3d normal = Vector3d.UnitZ;
            Dictionary<ApplicationRegistry, XData> xData = new Dictionary<ApplicationRegistry, XData>();

            code = this.ReadCodePair();
            while (code.Code != 0)
            {
                switch (code.Code)
                {
                    case 5:
                        solid.Handle = code.Value;
                        code = this.ReadCodePair();
                        break;
                    case 8: //layer code
                        solid.Layer = this.GetLayer(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 62: //aci color code
                        solid.Color = new AciColor(short.Parse(code.Value));
                        code = this.ReadCodePair();
                        break;
                    case 6: //type line code
                        solid.LineType = this.GetLineType(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 10:
                        v0.X = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 20:
                        v0.Y = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 30:
                        v0.Z = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 11:
                        v1.X = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 21:
                        v1.Y = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 31:
                        v1.Z = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 12:
                        v2.X = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 22:
                        v2.Y = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 32:
                        v2.Z = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 13:
                        v3.X = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 23:
                        v3.Y = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 33:
                        v3.Z = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 70:
                        solid.Thickness = float.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 210:
                        normal.X = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 220:
                        normal.Y = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 230:
                        normal.Z = double.Parse(code.Value);
                        code = this.ReadCodePair();
                        break;
                    case 1001:
                        XData xDataItem = this.ReadXDataRecord(code.Value, ref code);
                        xData.Add(xDataItem.ApplicationRegistry, xDataItem);
                        break;
                    default:
                        if (code.Code >= 1000 && code.Code <= 1071)
                            throw new DxfInvalidCodeValueEntityException(code.Code, code.Value, this.file,
                                                                         "The extended data of an entity must start with the application registry code " + this.fileLine);

                        code = this.ReadCodePair();
                        break;
                }
            }

            solid.FirstVertex = v0;
            solid.SecondVertex = v1;
            solid.ThirdVertex = v2;
            solid.FourthVertex = v3;
            solid.Normal = normal;
            solid.XData = xData;
            return solid;
        }
コード例 #3
0
ファイル: DimensionBlock.cs プロジェクト: Core2D/netdxf
        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;
            }
        }
コード例 #4
0
ファイル: Writer.cs プロジェクト: steve-stanton/backsight
        private void WriteSolid(Solid solid)
        {
            if (this.activeSection != StringCode.EntitiesSection && !this.isBlockEntities)
            {
                throw new InvalidDxfSectionException(this.activeSection, this.file);
            }

            this.WriteCodePair(0, solid.CodeName);
            this.WriteCodePair(5, solid.Handle);
            this.WriteCodePair(100, SubclassMarker.Entity);
            this.WriteEntityCommonCodes(solid);
            this.WriteCodePair(100, SubclassMarker.Solid);

            this.WriteCodePair(10, solid.FirstVertex.X);
            this.WriteCodePair(20, solid.FirstVertex.Y);
            this.WriteCodePair(30, solid.FirstVertex.Z);

            this.WriteCodePair(11, solid.SecondVertex.X);
            this.WriteCodePair(21, solid.SecondVertex.Y);
            this.WriteCodePair(31, solid.SecondVertex.Z);

            this.WriteCodePair(12, solid.ThirdVertex.X);
            this.WriteCodePair(22, solid.ThirdVertex.Y);
            this.WriteCodePair(32, solid.ThirdVertex.Z);

            this.WriteCodePair(13, solid.FourthVertex.X);
            this.WriteCodePair(23, solid.FourthVertex.Y);
            this.WriteCodePair(33, solid.FourthVertex.Z);

            this.WriteCodePair(39, solid.Thickness);

            this.WriteCodePair(210, solid.Normal.X);
            this.WriteCodePair(220, solid.Normal.Y);
            this.WriteCodePair(230, solid.Normal.Z);

            this.WriteXData(solid.XData);
        }
コード例 #5
0
        private static EntityObject EndArrowHead(Vector2 position, double rotation, DimensionStyle style)
        {
            Block block = style.DIMSAH ? style.DIMBLK2 : style.DIMBLK;

            if (block == null)
            {
                Vector2 arrowRef = Vector2.Polar(position, -style.DIMASZ*style.DIMSCALE, rotation);
                Solid arrow = new Solid(position,
                    Vector2.Polar(arrowRef, -(style.DIMASZ/6)*style.DIMSCALE, rotation + MathHelper.HalfPI),
                    Vector2.Polar(arrowRef, (style.DIMASZ/6)*style.DIMSCALE, rotation + MathHelper.HalfPI))
                {
                    Color = style.DIMCLRD
                };
                return arrow;
            }
            else
            {
                Insert arrow = new Insert(block, position)
                {
                    Color = style.DIMCLRD,
                    Scale = new Vector3(style.DIMASZ*style.DIMSCALE),
                    Rotation = rotation*MathHelper.RadToDeg
                };
                return arrow;
            }
        }
コード例 #6
0
ファイル: DxfReader.cs プロジェクト: Core2D/netdxf
        private Solid ReadSolid()
        {
            Vector3 v0 = Vector3.Zero;
            Vector3 v1 = Vector3.Zero;
            Vector3 v2 = Vector3.Zero;
            Vector3 v3 = Vector3.Zero;
            double thickness = 0.0;
            Vector3 normal = Vector3.UnitZ;
            List<XData> xData = new List<XData>();

            this.chunk.Next();
            while (this.chunk.Code != 0)
            {
                switch (this.chunk.Code)
                {
                    case 10:
                        v0.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 20:
                        v0.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 30:
                        v0.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 11:
                        v1.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 21:
                        v1.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 31:
                        v1.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 12:
                        v2.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 22:
                        v2.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 32:
                        v2.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 13:
                        v3.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 23:
                        v3.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 33:
                        v3.Z = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 70:
                        thickness = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 210:
                        normal.X = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 220:
                        normal.Y = this.chunk.ReadDouble();
                        this.chunk.Next();
                        break;
                    case 230:
                        normal.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;
                }
            }

            Solid entity = new Solid
            {
                FirstVertex = new Vector2(v0.X, v0.Y),
                SecondVertex = new Vector2(v1.X, v1.Y),
                ThirdVertex = new Vector2(v2.X, v2.Y),
                FourthVertex = new Vector2(v3.X, v3.Y),
                Elevation = v0.Z,
                Thickness = thickness,
                Normal = normal
            };

            entity.XData.AddRange(xData);

            return entity;
        }
コード例 #7
0
        /// <summary>
        /// Gets the the block that contains the entities that make up the dimension picture.
        /// </summary>
        /// <param name="name">Name to be asigned to the generated block.</param>
        /// <returns>The block that represents the actual dimension.</returns>
        internal override Block BuildBlock(string name)
        {
            // we will build the dimension block in object coordinates with normal the dimension normal
            Vector3 refPoint = MathHelper.Transform(this.startFirstLine, this.normal,
                                                    MathHelper.CoordinateSystem.World,
                                                    MathHelper.CoordinateSystem.Object);
            Vector2 refStartFirst = new Vector2(refPoint.X, refPoint.Y);
            double  elev          = refPoint.Z;

            refPoint = MathHelper.Transform(this.endFirstLine, this.normal,
                                            MathHelper.CoordinateSystem.World,
                                            MathHelper.CoordinateSystem.Object);
            Vector2 refEndFirst = new Vector2(refPoint.X, refPoint.Y);

            refPoint = MathHelper.Transform(this.startSecondLine, this.normal,
                                            MathHelper.CoordinateSystem.World,
                                            MathHelper.CoordinateSystem.Object);
            Vector2 refStartSecond = new Vector2(refPoint.X, refPoint.Y);

            refPoint = MathHelper.Transform(this.endSecondLine, this.normal,
                                            MathHelper.CoordinateSystem.World,
                                            MathHelper.CoordinateSystem.Object);
            Vector2 refEndSecond = new Vector2(refPoint.X, refPoint.Y);

            double  startAngle = Vector2.Angle(refStartFirst, refEndFirst);
            double  endAngle   = Vector2.Angle(refStartSecond, refEndSecond);
            Vector2 centerRef;

            MathHelper.FindIntersection(refStartFirst, refEndFirst - refStartFirst, refStartSecond, refEndSecond - refStartSecond, out centerRef);

            // reference points
            Layer defPoints = new Layer("Defpoints")
            {
                Plot = false
            };
            Point startFirstPoint = new Point(refStartFirst)
            {
                Layer = defPoints
            };
            Point endFirstPoint = new Point(refEndFirst)
            {
                Layer = defPoints
            };
            Point startSecondPoint = new Point(refStartSecond)
            {
                Layer = defPoints
            };
            Point endSecondPoint = new Point(refEndSecond)
            {
                Layer = defPoints
            };

            // dimension lines
            Vector2 startArc    = Vector2.Polar(centerRef, this.offset, startAngle);
            Line    startBorder = new Line(Vector2.Polar(refEndFirst, this.style.DIMEXO, startAngle),
                                           Vector2.Polar(startArc, this.style.DIMEXE, startAngle));

            Vector2 endArc    = Vector2.Polar(centerRef, this.offset, endAngle);
            Line    endBorder = new Line(Vector2.Polar(refEndSecond, this.style.DIMEXO, endAngle),
                                         Vector2.Polar(endArc, this.style.DIMEXE, endAngle));

            Arc dimArc = new Arc(centerRef, this.offset, startAngle * MathHelper.RadToDeg, endAngle * MathHelper.RadToDeg);

            // dimension arrows
            Vector2 arrowRefBegin = Vector2.Polar(startArc, this.style.DIMASZ, startAngle + MathHelper.HalfPI);
            Solid   arrowBegin    = new Solid(startArc,
                                              Vector2.Polar(arrowRefBegin, -this.style.DIMASZ / 6, startAngle),
                                              Vector2.Polar(arrowRefBegin, this.style.DIMASZ / 6, startAngle),
                                              startArc);

            Vector2 arrowRefEnd = Vector2.Polar(endArc, -this.style.DIMASZ, endAngle + MathHelper.HalfPI);
            Solid   arrowEnd    = new Solid(endArc,
                                            Vector2.Polar(arrowRefEnd, this.style.DIMASZ / 6, endAngle),
                                            Vector2.Polar(arrowRefEnd, -this.style.DIMASZ / 6, endAngle),
                                            endArc);

            // dimension text
            double  aperture = this.Value;
            double  rotText  = Vector2.Angle(endArc, startArc);
            Vector2 midText  = Vector2.Polar(centerRef, this.offset + this.style.DIMGAP, startAngle + aperture * MathHelper.DegToRad * 0.5);

            this.definitionPoint    = this.endSecondLine;
            this.midTextPoint       = new Vector3(midText.X, midText.Y, elev); // this value is in OCS
            this.arcDefinitionPoint = this.midTextPoint;                       // this value is in OCS

            MText text = new MText(this.FormatDimensionText(aperture),
                                   this.midTextPoint,
                                   this.style.DIMTXT, 0.0, this.style.TextStyle)
            {
                AttachmentPoint = MTextAttachmentPoint.BottomCenter,
                Rotation        = rotText * MathHelper.RadToDeg
            };

            // drawing block
            Block dim = new Block(name, false);

            dim.Entities.Add(startFirstPoint);
            dim.Entities.Add(endFirstPoint);
            dim.Entities.Add(startSecondPoint);
            dim.Entities.Add(endSecondPoint);
            dim.Entities.Add(startBorder);
            dim.Entities.Add(endBorder);
            dim.Entities.Add(dimArc);
            dim.Entities.Add(arrowBegin);
            dim.Entities.Add(arrowEnd);
            dim.Entities.Add(text);
            this.block = dim;
            return(dim);
        }
コード例 #8
0
        /// <summary>
        /// Creates a new Solid that is a copy of the current instance.
        /// </summary>
        /// <returns>A new Solid that is a copy of this instance.</returns>
        public override object Clone()
        {
            Solid entity = new Solid
            {
                //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,
                //Solid properties
                FirstVertex = this.firstVertex,
                SecondVertex = this.secondVertex,
                ThirdVertex = this.thirdVertex,
                FourthVertex = this.fourthVertex,
                Thickness = this.thickness
            };

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

            return entity;

        }
コード例 #9
0
        /// <summary>
        /// Gets the the block that contains the entities that make up the dimension picture.
        /// </summary>
        /// <param name="name">Name to be asigned to the generated block.</param>
        /// <returns>The block that represents the actual dimension.</returns>
        internal override Block BuildBlock(string name)
        {
            // we will build the dimension block in object coordinates with normal the dimension normal
            Vector3 refPoint = MathHelper.Transform(this.firstRef, this.normal,
                                                    MathHelper.CoordinateSystem.World,
                                                    MathHelper.CoordinateSystem.Object);

            Vector2 firstRef = new Vector2(refPoint.X, refPoint.Y);

            refPoint = MathHelper.Transform(this.secondRef, this.normal,
                                            MathHelper.CoordinateSystem.World,
                                            MathHelper.CoordinateSystem.Object);

            Vector2 secondRef   = new Vector2(refPoint.X, refPoint.Y);
            double  elev        = refPoint.Z;
            double  refRotation = Vector2.Angle(firstRef, secondRef);


            Vector2 startDimLine = Vector2.Polar(firstRef, this.offset, refRotation + MathHelper.HalfPI);
            Vector2 endDimLine   = Vector2.Polar(secondRef, this.offset, refRotation + MathHelper.HalfPI);



            // reference points
            Layer defPoints = new Layer("Defpoints")
            {
                Plot = false
            };
            Point startRef = new Point(firstRef)
            {
                Layer = defPoints
            };
            Point endRef = new Point(secondRef)
            {
                Layer = defPoints
            };
            Point defPoint = new Point(endDimLine)
            {
                Layer = defPoints
            };

            // dimension lines
            double offsetRot = 0.0;

            if (this.offset < 0)
            {
                offsetRot = MathHelper.PI;
            }
            Line startBorder = new Line(Vector2.Polar(firstRef, this.style.DIMEXO, offsetRot + refRotation + MathHelper.HalfPI),
                                        Vector2.Polar(startDimLine, this.style.DIMEXE, offsetRot + refRotation + MathHelper.HalfPI));

            Line endBorder = new Line(Vector2.Polar(secondRef, this.style.DIMEXO, offsetRot + refRotation + MathHelper.HalfPI),
                                      Vector2.Polar(endDimLine, this.style.DIMEXE, offsetRot + refRotation + MathHelper.HalfPI));

            Line dimLine = new Line(startDimLine, endDimLine);

            this.definitionPoint = MathHelper.Transform(new Vector3(endDimLine.X, endDimLine.Y, elev), this.normal,
                                                        MathHelper.CoordinateSystem.Object,
                                                        MathHelper.CoordinateSystem.World);

            Vector2 midDimLine = Vector2.MidPoint(startDimLine, endDimLine);

            // dimension arrows
            Vector2 arrowRefBegin = Vector2.Polar(startDimLine, this.style.DIMASZ, refRotation);
            Vector2 arrowRefEnd   = Vector2.Polar(endDimLine, -this.style.DIMASZ, refRotation);

            Solid arrowBegin = new Solid(startDimLine,
                                         Vector2.Polar(arrowRefBegin, -this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                         Vector2.Polar(arrowRefBegin, this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                         startDimLine);

            Solid arrowEnd = new Solid(endDimLine,
                                       Vector2.Polar(arrowRefEnd, this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                       Vector2.Polar(arrowRefEnd, -this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                       endDimLine);

            // dimension text
            this.midTextPoint = new Vector3(midDimLine.X, midDimLine.Y, elev); // this value is in OCS
            MText text = new MText(this.FormatDimensionText(this.Value),
                                   Vector2.Polar(midDimLine, this.style.DIMGAP, refRotation + MathHelper.HalfPI),
                                   this.style.DIMTXT, 0.0, this.style.TextStyle)
            {
                AttachmentPoint = MTextAttachmentPoint.BottomCenter,
                Rotation        = refRotation * MathHelper.RadToDeg
            };

            // drawing block
            Block dim = new Block(name);

            dim.Entities.Add(startRef);
            dim.Entities.Add(endRef);
            dim.Entities.Add(defPoint);
            dim.Entities.Add(startBorder);
            dim.Entities.Add(endBorder);
            dim.Entities.Add(dimLine);
            dim.Entities.Add(arrowBegin);
            dim.Entities.Add(arrowEnd);
            dim.Entities.Add(text);
            this.block = dim;
            return(dim);
        }
コード例 #10
0
        /// <summary>
        /// Gets the the block that contains the entities that make up the dimension picture.
        /// </summary>
        /// <param name="name">Name to be asigned to the generated block.</param>
        /// <returns>The block that represents the actual dimension.</returns>
        internal override Block BuildBlock(string name)
        {
            // we will build the dimension block in object coordinates with normal the dimension normal
            Vector3 refPoint = MathHelper.Transform(this.definitionPoint, this.normal,
                                                    MathHelper.CoordinateSystem.World,
                                                    MathHelper.CoordinateSystem.Object);

            Vector2 firstRef    = new Vector2(refPoint.X, refPoint.Y);
            double  elev        = refPoint.Z;
            double  refRotation = this.rotation * MathHelper.DegToRad;
            Vector2 secondRef   = Vector2.Polar(firstRef, this.radius, refRotation);

            this.circunferencePoint = MathHelper.Transform(new Vector3(secondRef.X, secondRef.Y, elev), this.normal,
                                                           MathHelper.CoordinateSystem.Object,
                                                           MathHelper.CoordinateSystem.World);
            // reference points
            Layer defPoints = new Layer("Defpoints")
            {
                Plot = false
            };
            Point startRef = new Point(firstRef)
            {
                Layer = defPoints
            };
            Point endRef = new Point(secondRef)
            {
                Layer = defPoints
            };

            // dimension lines
            Line dimLine = new Line(firstRef, secondRef);

            // center cross
            double  dist       = Math.Abs(this.style.DIMCEN);
            Vector2 c1         = new Vector2(0, -dist) + firstRef;
            Vector2 c2         = new Vector2(0, dist) + firstRef;
            Line    crossLine1 = new Line(c1, c2);

            c1 = new Vector2(-dist, 0) + firstRef;
            c2 = new Vector2(dist, 0) + firstRef;
            Line crossLine2 = new Line(c1, c2);

            // dimension arrows
            Vector2 arrowRef = Vector2.Polar(secondRef, -this.style.DIMASZ, refRotation);
            Solid   arrow    = new Solid(secondRef,
                                         Vector2.Polar(arrowRef, this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                         Vector2.Polar(arrowRef, -this.style.DIMASZ / 6, refRotation + MathHelper.HalfPI),
                                         secondRef);


            // dimension text
            Vector2 midDimLine = Vector2.MidPoint(firstRef, secondRef);

            this.midTextPoint = new Vector3(midDimLine.X, midDimLine.Y, elev); // this value is in OCS
            MText text = new MText(this.FormatDimensionText(this.Value),
                                   Vector2.Polar(midDimLine, this.style.DIMGAP, refRotation + MathHelper.HalfPI),
                                   this.style.DIMTXT, 0.0, this.style.TextStyle)
            {
                AttachmentPoint = MTextAttachmentPoint.BottomCenter,
                Rotation        = refRotation * MathHelper.RadToDeg
            };

            Block dim = new Block(name, false);

            dim.Entities.Add(startRef);
            dim.Entities.Add(endRef);
            dim.Entities.Add(dimLine);
            dim.Entities.Add(crossLine1);
            dim.Entities.Add(crossLine2);
            dim.Entities.Add(arrow);
            dim.Entities.Add(text);
            this.block = dim;
            return(dim);
        }
コード例 #11
0
        private static void SolidEntity()
        {
            // The solid vertexes are expressed in OCS (object coordinate system)
            // Now they are stored as Vector2 to force all vertexes to lay on a plane, this is similar as how the LwPolyline works.
            // The Z coordinate is controlled by the elevation property of the Solid.
            Vector2 a = new Vector2(-1, -1);
            Vector2 b = new Vector2(1, -1);
            Vector2 c = new Vector2(-1, 1);
            Vector2 d = new Vector2(1, 1);

            Solid solid = new Solid(a, b, c, d);
            solid.Normal = new Vector3(1, 1, 0);

            solid.Elevation = 2;

            DxfDocument doc = new DxfDocument();
            doc.AddEntity(solid);
            doc.Save("SolidEntity.dxf");
        }
コード例 #12
0
        private static void Solid()
        {

            DxfDocument dxf = new DxfDocument();

            Solid solid = new Solid();
            solid.FirstVertex=new Vector2(0,0);
            solid.SecondVertex  = new Vector2(1, 0);
            solid.ThirdVertex  = new Vector2(0, 1);
            solid.FourthVertex  = new Vector2(1, 1);
            dxf.AddEntity(solid);

            dxf.Save("solid.dxf");
            //dxf = DxfDocument.Load("solid.dxf");
            //dxf.Save("solid.dxf");

        }
コード例 #13
0
ファイル: Program.cs プロジェクト: steve-stanton/backsight
        private static void Solid()
        {
            DxfDocument dxf = new DxfDocument();

            Solid solid = new Solid();
            solid.FirstVertex=new Vector3d(0,0,0);
            solid.SecondVertex  = new Vector3d(1, 0, 0);
            solid.ThirdVertex  = new Vector3d(0, 1, 0);
            solid.FourthVertex  = new Vector3d(1, 1, 0);
            dxf.AddEntity(solid);

            dxf.Save("solid.dxf", DxfVersion.AutoCad2000);
            //dxf.Load("solid.dxf");
            //dxf.Save("solid.dxf");
        }