您可以使用该方法将命令直接发送到命令行。该方法将单个字符串发送到命令行。该字符串必须包含按已执行命令的提示序列所期望的顺序列出的命令的参数。SendStringToExecuteSendStringToExecute 字符串中回车符的空格或 ASCII 等效项等效于在键盘上按 Enter。与 AutoLISP 环境不同,调用不带参数的方法无效。SendStringToExecute 执行的命令是异步的,在 .NET 命令结束之前不会调用。如果需要立即(同步)执行命令,则应:SendStringToExecute
向命令行发送命令下面的示例创建一个圆,其中心为 (2, 2, 0),半径为 4。然后,绘图将缩放到绘图中的所有几何图形。请注意,字符串末尾有一个空格,表示开始执行命令的最后一个 Enter。 VB.NETImports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.Runtime <CommandMethod("SendACommandToAutoCAD")> _ Public Sub SendACommandToAutoCAD() Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument '' Draws a circle and zooms to the extents or '' limits of the drawing acDoc.SendStringToExecute("._circle 2,2,0 4 ", True, False, False) acDoc.SendStringToExecute("._zoom _all ", True, False, False) End Sub C#using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime; [CommandMethod("SendACommandToAutoCAD")] public static void SendACommandToAutoCAD() { Document acDoc = Application.DocumentManager.MdiActiveDocument; // Draws a circle and zooms to the extents or // limits of the drawing acDoc.SendStringToExecute("._circle 2,2,0 4 ", true, false, false); acDoc.SendStringToExecute("._zoom _all ", true, false, false); } VBA/ActiveX 代码参考Sub SendACommandToAutoCAD() ' Draws a circle and zooms to the extents or ' limits of the drawing ThisDrawing.SendCommand "._Circle 2,2,0 4 " ThisDrawing.SendCommand "._zoom a " End Sub 相关概念父主题: |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:36
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.