AutoCAD Civil 3D Help: Adding Point Data to a TIN Surface
为三角网添加点数据
有2个方法可以给三角网曲面添加点:
- 使用点文件
- 使用点编组
TinSurface.PointFilesDefinition属性中存有包含了点信息的文本文件的文件名。这些文本文件只能由包含了以空格隔开的点编号、坐标和高程所组成。除了以“#”开头的注释语句之外,任何其他内容均导致异常。和TIN和LandXML文件不同,文本文件不包括face的列表,点将会根据文档设置自动被加入到一系列三角形中。
PointFilesDefinition.AddPointFile()方法需要读取一个点文件的路径和一个PointFileFormat对象的ObjectId。这个对象从数据库的PointFileFormatCollection集合中取得,取得它时,会用到在Civil 3D界面中用于描述格式的字符串。
下面的例子为一个既存的曲面添加了一个PENZD格式的点文件。该文件来源于Civil 3D的教程文件夹。
[CommandMethod("SurfacePointFile")]
public void SurfacePointFile()
{
using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
// Select the first Surface in the document
ObjectId surfaceId = doc.GetSurfaceIds()[0];
TinSurface oSurface = surfaceId.GetObject(OpenMode.ForRead) as TinSurface;
try
{
// add points from a point file to the surface
// this is the location of an example PENZD file from the C3D tutorials, the actual path may
// differ based on the OS
string penzdFile = @"C:\Program Files\Autodesk\AutoCAD Civil 3D 2013\Help\Civil Tutorials\EG-Surface-PENZD (space delimited).txt";
// get the point file format object, required for import:
PointFileFormatCollection ptFileFormats = PointFileFormatCollection.GetPointFileFormats(HostApplicationServices.WorkingDatabase);
ObjectId ptFormatId = ptFileFormats["PENZD (space delimited)"];
oSurface.PointFilesDefinition.AddPointFile(penzdFile, ptFormatId);
}
catch (System.Exception e)
{
editor.WriteMessage("Failed: {0}", e.Message);
}
// commit the transaction
ts.Commit();
}
}
父主题: