.NET

Reply
Contributor
cctbailey
Posts: 17
Registered: ‎11-29-2005
Message 1 of 16 (172 Views)

Getting Started with VB .NET with AutoCAD

172 Views, 15 Replies
11-29-2005 02:30 PM
Hi! I am picking up on a program that a colleague of mine started before he left the company. The program is supposed to create and print plot files. I am trying just to get a feel for using VB .NET to program for AutoCAD before I delve in, and I am confused. I tried downloading the labs located at http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627, but on the second one (Lab2.doc) it mentions that I need to install the ObjectARX wizard. When I try to download and install the wizard, it says you must use Visual C++ to program, and then it gives me an error message when I try to install it. I am running Visual Studio 2003 but I don't have C++, I don't think. I am new to .NET and am very confused now as to what I need to do to just get started. Can someone please point me in the right direction?

Thanks!
Christy
*Rob Outman
Message 2 of 16 (172 Views)

Re: Getting Started with VB .NET with AutoCAD

11-29-2005 04:07 PM in reply to: cctbailey
Hi Christy,

Unless I am wrong (would a Guru please chime in here) you should not need
it.

See this thread:

http://discussion.autodesk.com/thread.jspa?threadID=423492

It appears VS2002 is needed in order to "properly" install the ObjectArx
wizard.

That's all I know... HIH

Rob


wrote in message news:5025008@discussion.autodesk.com...
Hi! I am picking up on a program that a colleague of mine started before he
left the company. The program is supposed to create and print plot files.
I am trying just to get a feel for using VB .NET to program for AutoCAD
before I delve in, and I am confused. I tried downloading the labs located
at http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627, but
on the second one (Lab2.doc) it mentions that I need to install the
ObjectARX wizard. When I try to download and install the wizard, it says
you must use Visual C++ to program, and then it gives me an error message
when I try to install it. I am running Visual Studio 2003 but I don't have
C++, I don't think. I am new to .NET and am very confused now as to what I
need to do to just get started. Can someone please point me in the right
direction?

Thanks!
Christy
Distinguished Contributor
saluki
Posts: 188
Registered: ‎09-18-2005
Message 3 of 16 (172 Views)

Re: Getting Started with VB .NET with AutoCAD

11-29-2005 08:51 PM in reply to: cctbailey
If the app was/is going to be written in vb.net you won't need to use ObjectARX (ARX is only for use with C++).

There are many posts out there comparing .net with arx. Basically ARX gives you access to the entire autocad model (it's what autocad programers use). For most user's the .net API will be more than adequate.

Depending on what version/platform of autocad you are using you should have some .net sample files located in a directory similar to:

C:\Program Files\Autodesk Product\Sample\Autodesk Product API\vb.net

This will provide you a starting point.

I'm recently started learning .net as well. The sample will get you started in the right direction and the discussion groups are helpful if you have questions.

If the program is pretty complex you may want to pick a simpler task that you would like to automate and make that your first .net project to help you get started.

Good luck!
*Rob Outman
Message 4 of 16 (172 Views)

Re: Getting Started with VB .NET with AutoCAD

11-30-2005 10:49 AM in reply to: cctbailey
I think I may have misspoke about the need for the ObjectArx wizard. After
attempting the same lab you are attempting (Lab2), I now see that you need
to create a new project using the "AutoCAD Managed VB Project Application"
template in the lab. If the ObjectArx wizard does not install properly,
then the "AutoCAD Managed VB Project Application" template is not available.

I am not sure how to resolve the install issue unless you have VS 2002
available.

You can however still complete the lab by doing the following:

Start VB and create a new project using the "Class Library" as a template.
Open the Class1.vb (from the Lab2) directory) in wordpad and copy the code.
Paste the code into the Class1 code editor and manually load the references
to the AutoCAD .NET managed wrappers as you did in Lab1. Compile the
program and load it using Netload (as in Lab1) and all should function fine
(at least it did for me).

I assume the "AutoCAD Managed VB Project Application" template creates a
class with a couple of functions in it as well as "pre-loads" the required
AutoCAD managed wrappers??? Can someone with VS2002 confirm this?

I hope this helps!

Rob


wrote in message news:5025008@discussion.autodesk.com...
Hi! I am picking up on a program that a colleague of mine started before he
left the company. The program is supposed to create and print plot files.
I am trying just to get a feel for using VB .NET to program for AutoCAD
before I delve in, and I am confused. I tried downloading the labs located
at http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627, but
on the second one (Lab2.doc) it mentions that I need to install the
ObjectARX wizard. When I try to download and install the wizard, it says
you must use Visual C++ to program, and then it gives me an error message
when I try to install it. I am running Visual Studio 2003 but I don't have
C++, I don't think. I am new to .NET and am very confused now as to what I
need to do to just get started. Can someone please point me in the right
direction?

Thanks!
Christy
Contributor
cctbailey
Posts: 17
Registered: ‎11-29-2005
Message 5 of 16 (172 Views)

Re: Getting Started with VB .NET with AutoCAD

11-30-2005 11:07 AM in reply to: cctbailey
Thank you for the information. I have found that I do not need the wizard in order to complete the lab (as another user posted). However I am very confused as to what I do need. For one thing, I have read that Visual Studio 2003 is not compatible with AutoCAD 2004 and above, and that I should downgrade to 2002. Can anyone verify this for me? It costs $20 to downgrade plus the hassle, and I'd rather not bother if it's not necessary.

Also, I have been able to complete these labs, but they are all library class projects (meaning there is no form), and mine is a Windows application that has a form that needs to access AutoCAD. However I cannot get my form to communicate with AutoCAD. I am going to post my specific question in a new topic. I will check out the .net sample files you gave me - thanks so much and I would very much appreciate any further help.

Thanks,
Christy
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 6 of 16 (172 Views)

Re: Getting Started with VB .NET with AutoCAD

12-01-2005 06:27 AM in reply to: cctbailey
You can use any VS version with the .NET API. It is ObjectARX which is VS version dependent.

Regards - Nathan
*James Stergar
Message 7 of 16 (172 Views)

Re: Getting Started with VB .NET with AutoCAD

12-01-2005 11:06 AM in reply to: cctbailey
Here's what I pulled out from my "main" class that was created via the
wizard:

Imports System

Imports System.Type

Imports System.CLSCompliantAttribute

Imports System.Reflection

Imports System.Runtime.InteropServices

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.Geometry

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.EditorInput

Imports Autodesk.AutoCAD.Interop

Imports Autodesk.AutoCAD.Interop.Common

< extensionapplication="">

< commandclass="">

Public Class AppMain

Implements Autodesk.AutoCAD.Runtime.IExtensionApplication


Public Sub Initialize() Implements
Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize

' insert your startup code here



End Sub

Private Sub Terminate() Implements
Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate

End Sub

End Class



"Rob Outman" wrote in message
news:5025800@discussion.autodesk.com...
I assume the "AutoCAD Managed VB Project Application" template creates a
class with a couple of functions in it as well as "pre-loads" the required
AutoCAD managed wrappers??? Can someone with VS2002 confirm this?
*Rob Outman
Message 8 of 16 (172 Views)

Re: Getting Started with VB .NET with AutoCAD

12-01-2005 11:51 AM in reply to: cctbailey
Hi James!

Thanks for the breakdown.

It's funny, I imported the code from Lab3 that was provided with the
download and the loading of AutoCAD actually works with VB 2005 express
without the ObjectArx wizard installed. So, it's hiding in there somewhere!

I am not guru enough to figure it out though... I will leave that to the big
boys!

Rob


"James Stergar" wrote in message
news:5026958@discussion.autodesk.com...
Here's what I pulled out from my "main" class that was created via the
wizard:

Imports System

Imports System.Type

Imports System.CLSCompliantAttribute

Imports System.Reflection

Imports System.Runtime.InteropServices

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.Geometry

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.EditorInput

Imports Autodesk.AutoCAD.Interop

Imports Autodesk.AutoCAD.Interop.Common

< extensionapplication="">

< commandclass="">

Public Class AppMain

Implements Autodesk.AutoCAD.Runtime.IExtensionApplication


Public Sub Initialize() Implements
Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize

' insert your startup code here



End Sub

Private Sub Terminate() Implements
Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate

End Sub

End Class



"Rob Outman" wrote in message
news:5025800@discussion.autodesk.com...
I assume the "AutoCAD Managed VB Project Application" template creates a
class with a couple of functions in it as well as "pre-loads" the required
AutoCAD managed wrappers??? Can someone with VS2002 confirm this?
Contributor
cctbailey
Posts: 17
Registered: ‎11-29-2005
Message 9 of 16 (172 Views)

Re: Getting Started with VB .NET with AutoCAD

12-01-2005 12:21 PM in reply to: cctbailey
Thanks for the additional information. It turns out that I don't think I can do what I need to do because my application is a WIndows application (.exe file) rather than a class library (.dll file). Apparently the ObjectARX managed wrappers only work in a dll. I am probably going to switch to VBA, unless I can maybe make a dll to do the AutoCAD stuff that i can then insert into the WIndows Application and use. I'm not sure how viable that option is, though.

Thanks,
Christy
Active Member
mike.king
Posts: 7
Registered: ‎12-01-2005
Message 10 of 16 (172 Views)

Re: Getting Started with VB .NET with AutoCAD

12-01-2005 01:59 PM in reply to: cctbailey
It's perfectly viable. You need to write your AutoCAD specific code in a dll that gets loaded into AutoCAD which you then expose to out of process communication via .NET remoting (or some similar cross process communication tool). You can load acdbmgd.dll and acmgd.dll in your stand alone exe so that you can access all of the AutoCAD object types, enums, etc. then just pass them into the remotely enabled dll when you need access to a running AutoCAD instances internals. If you are new to .NET, however, you might just want to switch to VBA. I can post some code if there is interest.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!