VB.NET 2005 and AutoCAD 2008

VB.NET 2005 and AutoCAD 2008

Anonymous
Not applicable
1,738 Views
19 Replies
Message 1 of 20

VB.NET 2005 and AutoCAD 2008

Anonymous
Not applicable
Is anyone out there using VB.NET 2005 to interact with AutoCAD 2008?

I am having a devil of a time getting ANYTHING to work...

I could make VB.NET and AutoCAD 2004 party like old time buddies...

I can barely get VB.NET and AutoCAD 2008 to say "hello" to each other, let alone get them to WORK together.

Is there any way to get VB.NET to start AutoCAD 2008 if it is not running?

I have hundreds of hours of VB.NET/AutoCAD 2004 experience...maybe even a thousand hours...but I need some help getting this new AutoCAD 2008 and VB.NET to work together.

Is there anyone out there that can help me?
0 Likes
1,739 Views
19 Replies
Replies (19)
Message 2 of 20

Anonymous
Not applicable
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=773204

Take a look at "License and Download", and "Samples"
Fill the forms, register, download the "ObjectARX 2008"
install it and in the installation directory ..\ObjectARX 2008\utils\ObjARXWiz\ run the "ArxWizards.msi" to connect it to Visual Studio 2005. You'll be running and debugging in minutes.
I'm not sure it works with the Express Editions but I know there are workarounds to make them work together, look in this discussion for a sample.
By the way, i'm not sure AutoCAD 2004 is supported in VB. Net, always used VBA and Lisp at that time.
René
0 Likes
Message 3 of 20

Anonymous
Not applicable
I just went back to my VB.NET/AutoCAD 2008 program...it works.

Is there something about the following "Try-Catch-End Try" routine that will not allow AutoCAD 2008 to work?

Try
objAcad = GetObject(, "AutoCAD.Application.16")
Catch exc As Exception
Control.CheckForIllegalCrossThreadCalls = False
SplashScreen1.Hide()
objAcad = CreateObject("AutoCAD.Application.16")
MsgBox("Press OK when AutoCAD has started, " & (Chr(13)) & (Chr(10)) & _
" and your drawing has loaded...")
End Try

Please allow me to reiterate...this exact code works fine in AutoCAD 2004...

It is as if AutoCAD 2008 can't validate an existing (running) AutoCAD 2008 session...or if there is none existing, successfully start a new session.

It is as if it "rushes" the process and won't let AutoCAD 2008 fully start, before determing that the session is not running, and can not be started.

Any ideas, suggestions and/or discussion will be greatly appreciated!

Pete
0 Likes
Message 4 of 20

Anonymous
Not applicable
The OP is talking about COM automation, not ObjectARX API.

"reneram" wrote in message news:5839600@discussion.autodesk.com...
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=773204

Take a look at "License and Download", and "Samples"
Fill the forms, register, download the "ObjectARX 2008"
install it and in the installation directory ..\ObjectARX
2008\utils\ObjARXWiz\ run the "ArxWizards.msi" to connect it to Visual
Studio 2005. You'll be running and debugging in minutes.
I'm not sure it works with the Express Editions but I know there are
workarounds to make them work together, look in this discussion for a
sample.
By the way, i'm not sure AutoCAD 2004 is supported in VB. Net, always used
VBA and Lisp at that time.
René
0 Likes
Message 5 of 20

Anonymous
Not applicable
Hi Pete,

I myself use the Express version, I don't (can't) debug to AutoCAD.

But I believe "AutoCAD.Application.16" is for AutoCAD2004
AutoCAD.Application.16.1 = AutoCAD 2005
AutoCAD.Application.16.2 = AutoCAD 2006
AutoCAD.Application.17 = AutoCAD 2007
AutoCAD.Application.17.1 = AutoCAD 2008

Correct me if I'm wrong.
A. Caddie
0 Likes
Message 6 of 20

Anonymous
Not applicable
Does your program need to be stand alone or can it be loaded into AutoCAD?
0 Likes
Message 7 of 20

rdswords
Advocate
Advocate
Yeah, you are calling the wrong version number. That should be the fix you are looking for.
0 Likes
Message 8 of 20

Anonymous
Not applicable
I'm getting a real nasty feeling about AutoCAD 2008 and VB.NET...kind of like...THEY DO NOT PLAY WELL TOGETHER!

Somebody (VB.NET or AutoCAD 2008 via "AutoCAD.Application.17" or "AutoCAD.Application.17.1" or "AXDBLib.AcadRegisteredApplication.17" or "AXDBLib.AcadRegisteredApplication.17.1") can not detect a running instance of AutoCAD.

I am working on a stand alone application that will start AutoCAD 2008 if it is not running.

This is an EXTREMELY SIMPLE thing to do in AutoCAD 2004.

I am sure that there is an equally easy way to detect an existing instance of AutoCAD 2008...

Does anyone know how to do this?

What REFERENCES must I establish?
What IMPORTS must I state?

Sheesh, if just starting AutoCAD 2008 is this difficult, I can only imagine what's waiting for me as I try to port over my 5,000 lines of existing code...
0 Likes
Message 9 of 20

Anonymous
Not applicable
VB.NET 2005 and VB.NET 2008 both work fabulously with AutoCAD 2004...

Is anyone using VB.NET with AutoCAD 2008?

Ominously...I get zero hits when I Google "AXDBLib.AcadRegisteredApplication"...the AutoCAD 2008 equivalent of "AutoCAD.Application" in AutoCAD 2004...

(And in case you might be wondering "if 2004 worked so well, why's this guy trying to use 2008?"...answer - corporate decision...Autodesk no longer supports ACAD2004.)
0 Likes
Message 10 of 20

rdswords
Advocate
Advocate
Try this:

Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Public acadApp As AcadApplication
acadApp = CreateObject("AutoCAD.Application.17")
acadApp.Visible = True

It works for this guy: http://discussion.autodesk.com/thread.jspa?messageID=5737438
0 Likes
Message 11 of 20

Anonymous
Not applicable
Your AutoCAD vintage assignments are correct...

Now you have me wondering if I can debug to AutoCAD at home...I'm running AutoCAD 2004 and VS 2005 and VS 2008 on my home machine...I'll check that out and report back later.
0 Likes
Message 12 of 20

Anonymous
Not applicable
Starting AutoCAD 2008 ain't the problemo...

Detecting an existing instance of AutoCAD 2008 IS A PROBLEM (at least so far)...

My question remains!

Does anyone know of a way to detect an existing instance of AutoCAD 2008 with VB.NET?
0 Likes
Message 13 of 20

rdswords
Advocate
Advocate
So your code snippet still doesn't work if you correct the version number?

Try
objAcad = GetObject(, "AutoCAD.Application.17")
Catch exc As Exception
Control.CheckForIllegalCrossThreadCalls = False
SplashScreen1.Hide()
objAcad = CreateObject("AutoCAD.Application.17")
MsgBox("Press OK when AutoCAD has started, " & (Chr(13)) & (Chr(10)) & _
" and your drawing has loaded...")
End Try
0 Likes
Message 14 of 20

dsnodgrass
Advocate
Advocate
I don't have the answer to your question, but I do have a suggestion.

http://www.google.com/search?hl=en&rlz=1T4RNWN_en___US216&q=C%23++Running+Object+Table+&btnG=Search
0 Likes
Message 15 of 20

Anonymous
Not applicable
Hi,

Try the attachment, I tried it out as a test to be able to send a command to autocad. Of course some checks need to be done. like is a document open, no command active etc..., also if multiple AutoCAD sessions are active, which to select?

I don't remember where I got it from? probably here.
I hope it helps you.

A. Caddie
Win Xp Prr Sp2, AutoCAD 2008, VS2005 express
0 Likes
Message 16 of 20

Anonymous
Not applicable
I repeat.

Does your program need to be stand alone or can it be loaded into AutoCAD?
0 Likes
Message 17 of 20

Anonymous
Not applicable
The GetObject is what I used when programming to AutoCAD 2007 with MSAccess. It is a VBA thing, but you should be able to get to it as mentioned earlier.

IF GetObject fails then there are no open versions of autocad. Otherwise it always returned the very first opened AutoCAD still in memory. Worked well for my needs. Since then I have moved into VS2005 with AutoCAD2008 using VB.Net, and my system runs as a palette window inside of autoCAD, so I don't concern myself with opening ACAD.

Just to cheer you up tho, I have done lots of programming to AutoCAD 2008 wth .net 2.0 in VB.Net through VS2005, and most things work great, my code just sucks!!

jvj
0 Likes
Message 18 of 20

Anonymous
Not applicable
Thanks!

This looks quite interesting...
0 Likes
Message 19 of 20

Anonymous
Not applicable
Thanks to everyone for the suggestions and assistance!

I have decided that life is too short for these kinds of experiences to continue...hence, and forthwith, I'm moving to Costa Rica. I'm done trying to pull my own *** through knot holes of varying diameter...

OK, actually not...I ended up removing every reference to anything even remotely suggesting an association with AutoCAD...and restored only the "AutoCAD 2008 Type Library" reference...

Then I went through my code and hard coded the long name into each of 70 then resulting errors...and presto, my program came alive in AutoCAD 2008.

I think there was some kind of "directional" error with my specifying the reference "Autodesk.AutoCAD.Interop.Common"...at any rate, I'm moving along...

Thanks again to everyone!
0 Likes
Message 20 of 20

Anonymous
Not applicable
getobject(AutoCAD.Application) 2008
0 Likes