文档彩票走势图>>VectorDraw Developer Framework使用教程>>VDF常见问题整理(四十七):如何单击到多边形并选择该面
VDF常见问题整理(四十七):如何单击到多边形并选择该面
VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。
VectorDraw Developer Framework试用版下载
问:
如何单击到多边形并选择自己想要的一面?
答:
下面的代码使用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); } } } } } }
以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
=======================================================
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。
关注慧聚IT微信公众号 ???,了解产品的最新动态及最新资讯。