AutoCAD Civil 3D Help: Creating a TIN Surface using TinSurface.Create()
通过TinSurface.Create()创建一个三角网曲面
你可以创建一个空的三角网曲面,然后用TinSurface.Create()方法把它添加到文档的曲面集合中。这个方法有2个重载方法,一个指定了要采用的曲面样式,另外一个则采用了缺省的曲面样式。
本例用一个指定的曲面样式创建了一个新的三角网曲面,然后向其中添加一些随机的点数据。
[CommandMethod("CreateTINSurface")]
public void CreateTINSurface()
{
using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
string surfaceName = "ExampleTINSurface";
// Select a style to use
ObjectId surfaceStyleId = doc.Styles.SurfaceStyles[3];
// Create the surface
ObjectId surfaceId = TinSurface.Create(surfaceName, surfaceStyleId);
TinSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as TinSurface;
// Add some random points
Point3dCollection points = new Point3dCollection();
Random generator = new Random();
for (int i = 0; i
<
10; i++)
{
double x = generator.NextDouble() * 250;
double y = generator.NextDouble() * 250;
double z = generator.NextDouble() * 100;
points.Add(new Point3d(x, y, z));
}
surface.AddVertices(points);
// commit the create action
ts.Commit();
}
}
父主题: