文档半岛外围网上直营>>VectorDraw Developer Framework使用教程>>VDF常见问题整理(五十二):如何在非XY平面中创建多边形剖面线
VDF常见问题整理(五十二):如何在非XY平面中创建多边形剖面线
VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。该库还支持许多矢量和栅格输入和输出格式,包括本地PDF和SVG导出。
点击下载VectorDraw Developer Framework
问:如何在非X / Y平面中创建多边形剖面线?
答:创建剖面线时,多曲线和剖面线应在X / Y平面中,因此,如果在SAME中有折线,但在X / Y平面中没有,则需要将它们“带”到X / Y平面,然后创建多边形线让他们回到飞机上。参照以下代码:
private void Test()
{
vdDocument doc = vdFramedControl.BaseControl.ActiveDocument;
doc.New();
#region create 2 random polylines
// 我们将使用两个圆,以便从中获得一些随机的点来创建折线。
vdCircle cir1 = new vdCircle(doc, new gPoint(3, 2), 5);
vdCircle cir2 = new vdCircle(doc, new gPoint(3, 2), 2);
Vector vec = new Vector(0.3, 0.7, -0.2); vec.Normalize();
cir1.ExtrusionVector = vec;
cir2.ExtrusionVector = vec;
// 在同一个“随机”平面上产生了两个圆
//从中得到一些点,从而“拥有”两条折线
gPoints pts1 = cir1.geomMeasure(7); // 第1折线的点
gPoints pts2 = cir2.geomMeasure(4); // 第2折线的点
#endregion
Matrix mat = new Matrix(); // 这是这些圆所属的平面的矩阵
mat.SetToViewDirection(vec, 0.0d);
Matrix invmat = new Matrix(mat.GetInvertion());
// 为多边形创建曲线
vdPolyline pl = new vdPolyline(doc, pts1);
// 矢量应垂直于折线所在的平面,也可用CalculateNormal3P计算,如:
Vector vec2 = new Vector();
Vector.CalculateNormal3P(pl.VertexList[0] as gPoint, pl.VertexList[1] as gPoint, pl.VertexList[2] as gPoint, out vec2);
// 在这个例子中,我们已经从圆中得到了它,正如我们在上面设置的那样。
pl.ExtrusionVector = vec;
pl.Flag = VdConstPlineFlag.PlFlagCLOSE;
pl.Transformby(mat); // 我们需要把这些点放到X/Y平面上
pl.Update();
VectorDraw.Professional.vdCollections.vdCurves curves_Outer = new VectorDraw.Professional.vdCollections.vdCurves();
curves_Outer.AddItem(pl);
pl = new vdPolyline(doc, pts2);
pl.ExtrusionVector = vec;
pl.Flag = VdConstPlineFlag.PlFlagCLOSE;
pl.Transformby(mat); pl.Update(); // 我们需要把这些点放到X/Y平面上
VectorDraw.Professional.vdCollections.vdCurves curves_Inside = new VectorDraw.Professional.vdCollections.vdCurves();
curves_Inside.AddItem(pl);
//'创建polyhatch
vdPolyhatch onehatch = new vdPolyhatch(doc);
onehatch.PolyCurves.AddItem(curves_Outer);
onehatch.PolyCurves.AddItem(curves_Inside);
onehatch.HatchProperties = new VectorDraw.Professional.vdObjects.vdHatchProperties(VectorDraw.Professional.Constants.VdConstFill.VdFillModeSolid);
onehatch.Transformby(invmat); // 把它带到圆所在的平面上。
doc.Model.Entities.AddItem(onehatch);
//只是为了显示的原因添加圆圈。没有必要添加它们
cir1.PenColor.FromSystemColor(Color.Red);
cir2.PenColor.FromSystemColor(Color.Red);
doc.Model.Entities.AddItem(cir1);
doc.Model.Entities.AddItem(cir2);
doc.CommandAction.Zoom("E", 0, 0);
}
以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
=======================================================
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。

QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线