我的经验不是 C# 和 AutoCad。我接受过 AutoLISP 培训。但是知道 AC 是如何工作的,我想说你最好的选择是控制命令提示符,如此处所述。
根据您所说的,我假设您想打印模型空间中的任何内容;那是对的吗?
好吧,当您在 PaperSpace 中时,您可以通过._MSPACE
在命令行上键入来切换到 ModelSpace。这将使您能够通过 PSpace 中的一个洞在 MSpace 中工作——可以这么说。因此,如果 PSpace 中的布局没有显示 MSpace 的全部内容,您可以切换到 MSpace 并在命令行上输入z
或键入。zoom
然后,您将拥有任何用户使用该zoom
工具在模型空间内的所有选项(全部/中心/动态...)。All
可能是最好的选择。
因此,当用户单击您的按钮或输入您的别名时,您可以自动化整个过程。您可以切换到 MSpace-> 全部缩放 -> 绘图 -> 布局(要绘制的内容)。
更新:
我现在意识到我的链接没有将您带到我想要的特定主题。(?)
这是我认为您应该尝试的片段 -
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
[CommandMethod("selectEntireAutoCadDrawing")]
public static void selectEntireAutoCadDrawing()
{
//This sets up your doc. Not sure if this is the way you're doing it.
//I imagine you'd probably pass the doc into the method.
Document yourACDoc = Application.DocumentManager.MdiActiveDocument;
//When your plug-in is invoked the first thing I'd do is make sure they're
//in PaperSpace
yourACDoc.SendStringToExecute("tilemode 0 ");
//Next enable ModelSpace through PaperSpace.
yourACDoc.SendStringToExecute("_mspace ");
//Now we zoom to the extents of the drawing.
//Not sure about the bools at the end. The AC documentation has it there for a
//zoom all example but AC doesn't ask any further questions after selecting the
//all or extents zoom types and doesn't elaborate on it?
yourACDoc.SendStringToExecute("._zoom _extents "/*, true, false, false*/);
//Head back to PaperSpace
yourACDoc.SendStringToExecute("_pspace ");
}
此时,您的绘图应该都在 PaperSpace 中。现在继续执行其余的操作。
AC 命令行需要空格键、回车键,或者如果设置正确,则单击鼠标即可执行任何命令。这就是为什么某些参数之间有空格的原因。这样做很重要,否则它们将被解释为未知命令。
您可能需要尝试一下,查看 API 参考,或使用不同的缩放类型。如果您有多个具有不同风格的用户,尤其是在管理松散的商店中,缩放可能会变得很棘手。如果这将在人们意识到其局限性的环境中实施,那应该没问题。
另外 - 让自己熟悉 AC 会很好。您可以将命令行用作调试器,因为它会显示所有输入的命令和任何错误消息的列表。它还可以让您提前设计。只需在 AC 中输入命令,记下提示的顺序和目的并相应地编码。还有一种方法可以将动作记录到宏中,这是许多没有编程知识的人采用的方法。
祝你好运~