Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Autocad Instance VB6 control Application

Status
Not open for further replies.

lrfcbabe

Programmer
Jul 19, 2001
108
US
I have a VB app that looks at autocad to determine if a dwg is open. I have run into a problem if the user has more than one instance of Autocad running or if the dwg that is open still has an open command running such as Pan. This throws up a message and has an adverse affect on my app. With all that my question would be how do I loop through all the instances of Autocad. This is my code to loop through the dwg files to determine if it is open. If it is a message will inform them to save and close the file before my app can "Check the file in" or back to the server. Wasn't sure where to post this. Oh and I also need to pass either a Ctrl+C or an Escape character to each file to terminate any active commands.

Public Function AcadLink() As Boolean
Dim h, i As Integer
Dim DwgName As String

i = 0
AcadLink = False
On Error GoTo nocad

Set AcadApp = GetObject(, "AutoCAD.Application")
For i = 0 To AcadApp.Documents.Count - 1
DwgName = Left(Right(AcadApp.Documents(i).Name, Len(lstCitem) + 4), Len(lstCitem))
If lstCitem = DwgName Then
AcadLink = True
Exit For
End If
Next i
nocad:

End Function

Thanks
 
Hi Irfcbabe,

This probably won't be of much help, but I'm not sure VB is capable of collecting a list of running applications, the problem is the application class doesn't change, and neither does the path of the application. You'll need to look to the WindowsAPI to do what you need for that - start here:

The really tough issue here is trying to send in an ESC sequence or a Ctrl C. AutoCAD typically doesn't accept any incoming commands while a command is processing - in this sense - it's single threaded (it's not but the sake of argument - you get the idea). Most of our AutoCAD automation is forced to wait until AutoCAD allows commands in - maybe the WinAPI will offer you something here I'm not sure...

Sorry the news isn't better - maybe someone else will chime in here with better info...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top