有多个autocad时,如何传送命令到所有autocad或指定的?
本帖最后由 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
可能用到的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了
页:
[1]