.Net 与 AutoCad 的接口 - 如何进行选择

发布于 2024-11-11 13:32:03 字数 199 浏览 4 评论 0原文

如何选择绘图中的所有对象?

与 But 相关的东西

AcadSelectionSet select = _acadCurrentDocument.SelectionSets.Add("my");
select.Select(AcSelect.acSelectionSetAll);

无法使其发挥作用。

How to select all object within the drawing?

Sometthing related to

AcadSelectionSet select = _acadCurrentDocument.SelectionSets.Add("my");
select.Select(AcSelect.acSelectionSetAll);

But cannot make it working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆梦 2024-11-18 13:32:03

在真实的 .NET AutoCAD API 中(正在处理中,而不是像您的示例中那样的 C#/COM):

Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptSelectionResult psr = ed.GetSelection();
if (psr.Status != PromptStatus.OK) return;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
    foreach (SelectedObject so in psr.Value)
    {
        var dbo = tr.GetObject(so.ObjectId, OpenMode.ForRead);
        //...
    }
    tr.Commit();
}

In real .NET AutoCAD API (in process, not C#/COM like in your exemple):

Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptSelectionResult psr = ed.GetSelection();
if (psr.Status != PromptStatus.OK) return;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
    foreach (SelectedObject so in psr.Value)
    {
        var dbo = tr.GetObject(so.ObjectId, OpenMode.ForRead);
        //...
    }
    tr.Commit();
}
少女七分熟 2024-11-18 13:32:03

如果您想在独立的可执行文件中进行选择,AutoCAD COM Interop 就是您所尝试的方法。您可能需要了解 AutoCAD 是否已打开以及它是否是您喜欢的版本。

如有必要,您可能还需要激活 AutoCAD 窗口。

If you'd like to do the selection in a standalone executable, the AutoCAD COM Interop is the way to go as you were trying. You may need to if the AutoCAD has been open or not and if it's the version you like.

You may need to activate the AutoCAD window too if necessary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文