VectorDraw Developer Framework试用版下载
问:
如何单击到多边形并选择自己想要的一面/p>
答:
下面的代码使用Select3D,然后使用RenderSelect的各种方法来获取内部实体以及所选面所需的MAtrix。
private void TestIt() { vdDocument doc = vd.BaseControl.ActiveDocument; gPoint userpt = null; StatusCode s = doc.ActionUtility.getUserPoint(out userpt); if (s == StatusCode.Success) { gPoint pointW = doc.User2WorldMatrix.Transform(userpt); gPoint tmppt = doc.World2PixelMatrix.Transform(pointW); Point screenpt = new Point((int)tmppt.x, (int)tmppt.y); doc.EntitySelectMode = VectorDraw.Render.PickEntityMode.EyeNearest; //Very important so it is selected the eye nearest face , your drawing had default DrawOrder which in many occasions will return you the bottom face VectorDraw.Render.RenderSelect.RenterSelectObjectArray selectedents = null; doc.ActiveLayOut.Select3d(false, doc.ActiveLayOut.Entities, screenpt, doc.GlobalRenderProperties.PickSize, false, out selectedents); if (selectedents != null && selectedents.Count > 0) { VectorDraw.Render.RenderSelect.RenterSelectObject pfacerender = selectedents[0]; //Get the polyface vdPolyface pface = pfacerender.mFigStackItem[0].mFigure as vdPolyface; if (pface != null) { //The UserID gives you the segment of the polyface that was selected int SegCount = pfacerender.UserId; gPoints pts = new gPoints(); if (SegCount >= 0) { int seg = 5 * SegCount; if (seg <= (pface.FaceList.Count - 5)) { pts.Add(new gPoint(pface.VertexList[System.Math.Abs(pface.FaceList[seg + 0]) - 1])); pts.Add(new gPoint(pface.VertexList[System.Math.Abs(pface.FaceList[seg + 1]) - 1])); pts.Add(new gPoint(pface.VertexList[System.Math.Abs(pface.FaceList[seg + 2]) - 1])); if (pface.FaceList[seg + 3] != pface.FaceList[seg + 0]) pts.Add(new gPoint(pface.VertexList[System.Math.Abs(pface.FaceList[seg + 3]) - 1])); int[] array_faces = { 1, 2, 3, 4, -1 }; Int32Array faces = new Int32Array(array_faces); var pf = new vdPolyface(doc, pts, faces); //Calculate the Matrix to transform the face to World Coordinate System because the face is inside a block and has a completelly different coordinate system Matrix matt = pfacerender.mFigStackItem[0].mMatrix * doc.ActiveLayOut.View2WorldMatrix; pf.Transformby(matt); pf.PenColor.SystemColor = Color.BlueViolet; doc.ActionLayout.Entities.Add(pf); doc.Redraw(true); } } } } } }
以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
-
如何排除GroundSurface对象的三角形区域/strong>
-
复杂自定义对象的入门指南
=======================================================
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!