【发布时间】:2018-01-23 01:28:38
【问题描述】:
我正在为 Civil 3D 开发一个 IFC(工业基础类)导入/导出插件,我将在本月晚些时候作为开源发布)。导出功能已经完全正常。但是,我仍然不太了解如何使用 .NET 在 Civil 3D 中创建对象。我的加载项是用 C# 编写的。
我尝试了以下,这是一个官方的 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");
我还尝试用 null 或 ObjectID.Null 替换为对齐提供站点的 "",两者都不起作用并用 ObjectID.Null 替换它甚至会阻止我编译。
有人知道这个错误是从哪里来的吗?
【问题讨论】: