我正在開發一個用於Civil 3D的IFC(Industry Foundation Classes)導入/導出加載項,我將在本月晚些時候以開放源代碼的形式發佈)。導出功能已經完全正常。但是,我仍然不太瞭解如何使用.NET在Civil 3D中創建對象。我的加載項是用C#編寫的。在.Net中創建Civil 3D對齊會拋出「對齊ID無效」錯誤
我嘗試以下,這是Autodesk官方例子:
// Uses an existing Alignment Style named "Basic" and Label Set Style named "All Labels" (for example, from
// the _AutoCAD Civil 3D (Imperial) NCS.dwt template. This call will fail if the named styles
// don't exist.
// Uses layer 0, and no site (ObjectId.Null)
ObjectId testAlignmentID = Alignment.Create(doc, "New Alignment", ObjectId.Null, "0", "Basic", "All Labels");
但是,每當我嘗試運行我的代碼,我得到了以下錯誤消息:「無效對齊ID「。。我的代碼如下所示:
var civilDatabase = Application.DocumentManager.MdiActiveDocument.Database;
var civilDocument = CivilApplication.ActiveDocument;
using (Transaction civilTransactionManager =
civilDatabase.TransactionManager.StartTransaction())
{
ObjectId civilAlignment = Alignment.Create(civilDocument, "MyName", "" , "0", "Basic", "All Labels");
我也試圖替換給出了對齊現場與空或ObjectID.Null的「」,都不起作用,用它替換ObjectID.Null甚至阻止我編譯。
任何人都知道錯誤來自哪裏?