明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 991|回复: 1

有多个autocad时,如何传送命令到所有autocad或指定的?

[复制链接]
发表于 2011-1-7 15:59:08 | 显示全部楼层 |阅读模式
本帖最后由 xiaoyingzi 于 2011-1-7 16:01 编辑

有多个AutoCAD时,如何传送命令到所有autocad或指定的?
用GetObject和ThisDrawing.SendCommand 只能传送命令到第一个运行的autocad,因为GetObject默认第一个运行的autocad,
如何传送命令到所有autocad或正在激活状态的autocad?
下面是部分vbs源码
Set objCAD = GetObject(, "AutoCAD.Application")
Set ThisDrawing = objCAD.activedocument
ThisDrawing.SendCommand ("(if (member ""tch_initstart.arx"" (arx))(command ""tmnload""))(princ)" & vbCr)

试过用Object.Documents.Item(index)也不行

Set ObjCAD = GetObject(, "AutoCAD.Application")
count = ObjCAD.Documents.count
For index = 0 To count - 1
set ThisDrawing=ObjCAD.Documents.Item(index)
ThisDrawing.SendCommand ("(if (member ""tch_initstart.arx"" (arx))(command ""tmnload""))(princ)" & vbCr)
Next


发表于 2011-1-7 22:08:05 | 显示全部楼层
可能用到的API(附加API解释):  
'获取桌面的hwnd
    Public Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long     
'获取窗口hwnd
    Public Declare Function GetWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
'取得窗口caption
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
'激活某个窗口
    Public Declare Function SetActiveWindow Lib "user32" Alias "SetActiveWindow" (ByVal hwnd As Long) As Long
然后试试用getobject()如果这不行的话只能用windows API来 snap了   
   
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 20:53 , Processed in 0.167441 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表