VDF常见问题整理(三十六):如何读取对象的几何属性(gPoints)?

VectorDraw Developer Framework试用版下载


问:

    工程图后如何重新读取对象的几何特性(gPoints)/p>

答:

    您可以使用以下代码:

 private void ReadProps()        {            string msg = "";             System.Diagnostics.Debug.WriteLine("=====START====");            foreach (vdFigure item in vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities)            {                if (item is vdLine)                {//vdLine's geometry is defined by two gPoints; the StartPoint and the EndPoint//                    vdLine line = item as vdLine;                    msg = "vdLINE  StartPoint: " + line.StartPoint.ToString() + "   EndPoint: " + line.EndPoint.ToString();                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdPolyline)                {//vdpolyline's geometry is defined by the VertexList which is a collection of points (Vertex)//                    vdPolyline polyline = item as vdPolyline;                    msg = "vdPOLYLINE VertexList: " + polyline.VertexList.ToString()+ "rn";                    foreach (Vertex item2 in polyline.VertexList)                    {                        msg += item2.ToString() + "rn";                    }                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdCircle)                {//vdCircle's geometry is defined by the Center point and the Radius//                     vdCircle circle = item as vdCircle;                    msg = "vdCIRCLE Center: " + circle.Center.ToString() + "  Radius: " + circle.Radius.ToString();                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdRect)                {//vdRect's geometry is defined by the InsertionPoint and the Width//                    vdRect rect = item as vdRect;                    msg = "vdRECT Insertion Point: " + rect.InsertionPoint.ToString() + "  Width: " + rect.Width.ToString();                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdArc)                {//vdArc's geometry is defined by the Center point, the Radius, the StartAngle and the EndAngle//                    vdArc arc = item as vdArc;                    msg = "vdARC Center Point: " + arc.Center.ToString() + "  Radius: " + arc.Radius.ToString()                       + "  StartAngle: "+ arc.StartAngle.ToString()  + "  EndAngle: " + arc.EndAngle.ToString();                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdEllipse)                {//vdEllipse's geometry is defined by the Center point the StartAngle,the EndAngle,                      // the MajorAngle, MajorLength and the MinorLength//                    vdEllipse ellipse = item as vdEllipse;                    msg = "vdELLIPSE Center Point: " + ellipse.Center.ToString() + "  StartAngle: " + ellipse.StartAngle.ToString()                         + "  EndAngle: "  + ellipse.EndAngle.ToString() + "  MajorAngle: "  + ellipse.MajorAngle.ToString()                         +  "  MajorLength: " + ellipse.MajorLength.ToString() + "  MinorLength: " + ellipse.MinorLength.ToString();                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdText)                {//vdText's "geometry" is defined by the InsertionPoint, the Height and the Rotation//                    vdText text = item as vdText;                    msg = "vdTEXT Insertion Point: " + text.InsertionPoint.ToString() + "  Heihgt: " + text.Height.ToString()                       + "  RotationAngle: "+text.Rotation.ToString() + "  Text: " + text.TextString.ToString();                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdMText)                {//vdMText's "geometry" is defined by the InsertionPoint and the Height//                    vdMText mtext = item as vdMText;                    msg = "vdMTEXT Insertion Point: " + mtext.InsertionPoint.ToString() + "  Heihgt: " + mtext.Height.ToString()                           + "  Text: " + mtext.TextString.ToString();                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdInfinityLine)                {//vdInfinityLine's geometry is defined by the BasePoint and the Direction//                    vdInfinityLine xline = item as vdInfinityLine;                    msg = "vdXLINE Base Point: "+xline.BasePoint.ToString()+"  Direction: "+ xline.Direction.ToString();                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdPolyface)                {//vdPolyface's geometry is defined by the VertexList which is a collection of points (gPoint)//                    vdPolyface cone = item as vdPolyface;                    msg = "vdPOLYFACE VertexList: " + cone.VertexList.ToString() + "rn";                    foreach (gPoint item3 in cone.VertexList)                    {                        msg += item3.ToString() + "rn";                    }                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vdInsert)                {//vdInsert's geometry is defined by the InsertionPoint, the Rotation, the scales and of course the block's objects)//                    vdInsert insert = item as vdInsert;                    msg = "vdINSERT Block Name: " + insert.Block.Name.ToString() +  "  Insertion Point: " + insert.InsertionPoint.ToString()                     + "  RotationAngle: " + insert.Rotation.ToString() + "rn" + "vdINSERT Xscale: " + insert.Xscale.ToString() + "  Yscale: "                     + insert.Yscale.ToString() +  "  vdINSERT Zscale: " + insert.Zscale.ToString();                    System.Diagnostics.Debug.WriteLine(msg);                }                if (item is vd3DFace)                {//vd3DFace's geometry is defined by the VertexList which is a collection of points (gPoint)//                    vd3DFace face = item as vd3DFace;                    msg = "vd3DFACE VertexList: " + face.VertexList.ToString() + "rn";                    foreach (gPoint item4 in face.VertexList)                    {                        msg += item4.ToString() + "rn";                    }                    System.Diagnostics.Debug.WriteLine(msg);                }//vdPolyhatch's geometry is defined by the geometry of every vdCurve which that is consisted//                if (item is vdPolyhatch)                {                    vdPolyhatch hatch = item as vdPolyhatch;                    msg = "vdHATCH PolyCurves: " + hatch.PolyCurves.ToString() + "rn";                    foreach (vdCurves item2 in hatch.PolyCurves)                    {                        foreach (vdCurve item3 in item2)                        {                            msg += "PolyCurve: " + item3.ToString()+"rn";                        }                                            }                    System.Diagnostics.Debug.WriteLine(msg);                }            }            System.Diagnostics.Debug.WriteLine("=====END====");        }

    请注意,所有这些对象还具有一个定义这些对象中某些对象的平面的拉伸向量(如vdInsert,vdCircle,vdEllipse,vdArc,vdText / MText,vdPolyhatch)。

    对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。

热门文章推荐:

  • 如何排除GroundSurface对象的三角形区域/strong>

  • 复杂自定义对象的入门指南


    如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年10月9日
下一篇 2019年10月9日

相关推荐

发表回复

登录后才能评论