TheSwamp

Code Red => VB(A) => Topic started by: BazzaCAD on January 12, 2007, 04:06:47 PM

Title: Noob VB.exe Starting Acad.
Post by: BazzaCAD on January 12, 2007, 04:06:47 PM
Hi Guys, I've been a Lisp'er for a long time now, but ever since VB.NET 2005 Express came out I find myself trying new stuff with it. I have an old VB6.exe that I wrote to start Acad with my own splash screen. It starts Acad using Shell() & is working good for me since I can pass it command line argents when I start Acad. Now I want to update my App to Start Acad then min. down to the taskbar & still be able to interact with Acad. I got the taskbar part worked out (really easy with 2005 express), but I want to know what's the best way to start Acad & keep it's object so I can keep working with it. I read this post: http://www.theswamp.org/index.php?topic=9811.msg125738#msg125738 (http://www.theswamp.org/index.php?topic=9811.msg125738#msg125738) Which worked good, but I wasn't able to pass in the command line arguments when starting Acad. Then I started watching some of the training videos for Express & learned about the Process Control, which I can pass in the arguments, but I'm not sure how to keep or set the Acad object after it's been started. Can anyone give me any advice, tips, or code samples on the best way to do this?

Thx
Barry

Title: Re: Noob VB.exe Starting Acad.
Post by: Keith™ on January 12, 2007, 04:16:54 PM
You can grab the instance of the Acad application using this bit of code

Code: [Select]
Public Function GetAutoCAD() As Object
' Get a reference to AutoCAD
    Dim RefObj As Object
    On Error GoTo EoF
    Set RefObj = GetObject(, "AutoCAD.Application")
    Set GetAutoCAD = RefObj
EoF:
End Function

In your application create a global variable to hold the return value. If you don't want to utilize a global var, you can just grab the AutoCAD instance whenever you need it. Beware though .. if more than one session is open it may grab the wrong one.
Title: Re: Noob VB.exe Starting Acad.
Post by: BazzaCAD on January 12, 2007, 04:28:02 PM
Great thx, I thought it might be something like that.