文檔首頁>>VectorDraw Developer Framework使用教程>>VDF常見問題整理(三十六):如何讀取對象的幾何屬性(gPoints)?
VDF常見問題整理(三十六):如何讀取對象的幾何屬性(gPoints)?
VectorDraw Developer Framework(VDF)是一個用于應用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。
VectorDraw Developer Framework試用版下載
問:
工程圖后如何重新讀取對象的幾何特性(gPoints)?
答:
您可以使用以下代碼:
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()+ "\r\n"; foreach (Vertex item2 in polyline.VertexList) { msg += item2.ToString() + "\r\n"; } 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() + "\r\n"; foreach (gPoint item3 in cone.VertexList) { msg += item3.ToString() + "\r\n"; } 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() + "\r\n" + "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() + "\r\n"; foreach (gPoint item4 in face.VertexList) { msg += item4.ToString() + "\r\n"; } 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() + "\r\n"; foreach (vdCurves item2 in hatch.PolyCurves) { foreach (vdCurve item3 in item2) { msg += "PolyCurve: " + item3.ToString()+"\r\n"; } } System.Diagnostics.Debug.WriteLine(msg); } } System.Diagnostics.Debug.WriteLine("=====END===="); }
請注意,所有這些對象還具有一個定義這些對象中某些對象的平面的拉伸向量(如vdInsert,vdCircle,vdEllipse,vdArc,vdText / MText,vdPolyhatch)。
對于以上問答,如果您有任何的疑惑都可以在評論區(qū)留言,我們會及時回復。此系列的問答教程我們會持續(xù)更新,如果您感興趣,可以多多關(guān)注本教程。
熱門文章推薦:
如果您對想要購買正版授權(quán)VectorDraw Developer Framework(VDF),可以聯(lián)系在線客服>>咨詢相關(guān)問題。
關(guān)注慧聚IT微信公眾號 ???,了解產(chǎn)品的最新動態(tài)及最新資訊。