Message 1 of 12
SendCommand
Not applicable
10-24-2006
04:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi:
Can somebody please tell me if it is possible to Synchronously execute a command sent via SendCommand while using the COM/ActiveX interface in VB 2005? I know I can do this in VBA (in my particular application the commands executed via SendCommand are always complete and the program never needs to wait for user data), but I was hoping I could do the same using VB 2005. Unfortunately, so far I have not been able to do that. In the example below the SendCommand is executed after the file has been saved and I want it to execute before the file is saved. Can somebody please tell me if it is even possible to do what I want to do?
Any ideas would be greatly appreciated,
Raul
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports System.IO
Public Class ClsTest
>CommandMethod("Test")> _
Public Sub Test()
Dim OutputPath As String = "c:\Test\dwg"
Dim ObjAcad As AcadApplication
Dim ThisDrawing As AcadDocument
Dim Obj As Acad3DSolid
Dim ZeroOrgin() As Double = {0, 0, 0}
Dim Width as Double = 2
Dim Depth as Double = 4
Dim Length as Double = 8
Directory.Delete(OutputPath, True)
Directory.CreateDirectory(OutputPath)
ObjAcad = DirectCast(GetObject(, "AutoCAD.Application.17"), AcadApplication)
ObjAcad.Visible = True
ThisDrawing = ObjAcad.ActiveDocument
Obj = ThisDrawing.ModelSpace.AddBox(ZeroOrgin, Width, Depth, Length)
ThisDrawing.SendCommand("_zoom" & vbCr & "e" & vbCr)
' I was hoping the Do Loop below would be the answer to my problem,
' but IsQuiescent is never True and as a result the program hangs.
' Without the Do Loop, the SendCommand is not executed until after
' the drawing is saved, which is not what I want. Any ideas how to
' solve this problem?
Do Until ObjAcad.GetAcadState.IsQuiescent = True
Loop
ThisDrawing.SaveAs(OutputPath & "\Test.dwg")
End Sub
End Class
Can somebody please tell me if it is possible to Synchronously execute a command sent via SendCommand while using the COM/ActiveX interface in VB 2005? I know I can do this in VBA (in my particular application the commands executed via SendCommand are always complete and the program never needs to wait for user data), but I was hoping I could do the same using VB 2005. Unfortunately, so far I have not been able to do that. In the example below the SendCommand is executed after the file has been saved and I want it to execute before the file is saved. Can somebody please tell me if it is even possible to do what I want to do?
Any ideas would be greatly appreciated,
Raul
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports System.IO
Public Class ClsTest
>CommandMethod("Test")> _
Public Sub Test()
Dim OutputPath As String = "c:\Test\dwg"
Dim ObjAcad As AcadApplication
Dim ThisDrawing As AcadDocument
Dim Obj As Acad3DSolid
Dim ZeroOrgin() As Double = {0, 0, 0}
Dim Width as Double = 2
Dim Depth as Double = 4
Dim Length as Double = 8
Directory.Delete(OutputPath, True)
Directory.CreateDirectory(OutputPath)
ObjAcad = DirectCast(GetObject(, "AutoCAD.Application.17"), AcadApplication)
ObjAcad.Visible = True
ThisDrawing = ObjAcad.ActiveDocument
Obj = ThisDrawing.ModelSpace.AddBox(ZeroOrgin, Width, Depth, Length)
ThisDrawing.SendCommand("_zoom" & vbCr & "e" & vbCr)
' I was hoping the Do Loop below would be the answer to my problem,
' but IsQuiescent is never True and as a result the program hangs.
' Without the Do Loop, the SendCommand is not executed until after
' the drawing is saved, which is not what I want. Any ideas how to
' solve this problem?
Do Until ObjAcad.GetAcadState.IsQuiescent = True
Loop
ThisDrawing.SaveAs(OutputPath & "\Test.dwg")
End Sub
End Class