ポイント データを TIN サーフェスに追加する

TIN サーフェスに対して一意のポイントを追加するには、次の 2 通りの方法があります。

  1. ポイント ファイルを使用する
  2. ポイント グループを使用する

TinSurface.PointFilesDefinition プロパティには、ポイント情報を格納したテキスト ファイルの名前が含まれています。 これらのテキスト ファイルは、スペースで区切られたポイント番号、東座標、北座標、標高を含む線分だけで構成する必要があります。# で始まるコメント行を除き、それ以外の情報を指定するとエラーとなります。TIN または LandXML ファイルとは異なり、テキスト ファイルには面のリストは含まれていません。このため、ポイントはドキュメントの設定に基づいて一連の三角形に自動的に連結されます。

メソッド PointFilesDefinition.AddPointFile() には、ポイント ファイルのパス、および PointFileFormat オブジェクトの ObjectId を指定します。このオブジェクトは、Civil 3D GUI で形式を記述するために使用するのと同じ文字列を使用して、データベースの PointFileFormatCollection から取得します。

この例では、既存のサーフェスに 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();
    }
}