.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting Started with VB .NET with AutoCAD

15 REPLIES 15
Reply
Message 1 of 16
cctbailey
543 Views, 15 Replies

Getting Started with VB .NET with AutoCAD

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
15 REPLIES 15
Message 2 of 16
Anonymous
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
Message 3 of 16
saluki
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!
Message 4 of 16
Anonymous
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
Message 5 of 16
cctbailey
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
Message 6 of 16
NathTay
in reply to: cctbailey

You can use any VS version with the .NET API. It is ObjectARX which is VS version dependent.

Regards - Nathan
Message 7 of 16
Anonymous
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?
Message 8 of 16
Anonymous
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?
Message 9 of 16
cctbailey
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
Message 10 of 16
Anonymous
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.
Message 11 of 16
Anonymous
in reply to: cctbailey

Hi Christy,

I am just learning VB.NET too and I figured there HAS to be a way to bring a
form into the AutoCAD application so I started investigating it. I looked
through the DotNet samples directory installed with the ObjectARX SDK and
found exactly what I was looking for. If you create a new project using the
Class Library template, you can insert a "Windows Form" by clicking on the
"Add Class" button.

Use this code (from the sample "HelloWorld") to load the form into the
AutoCAD instance

' Defines a command which displays a Windows form
Public Function
HelloFormCmd()
Dim dlg As New frmHello()
dlg.ShowDialog()
End Function

Up to this point, I have found VBA to be much easier... I sure hope I get
better at this!

HIH

Rob


wrote in message news:5027063@discussion.autodesk.com...
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
Message 12 of 16
Anonymous
in reply to: cctbailey

I don't believe you can load acmdg.dll/acdbmgd.dll
into any other process (e.g., 'standalone EXE').

Also, many of the objects exposed by the managed
API are not remotable.

While one can write the AutoCAD-specific parts of
an application as a DLL that loads into AutoCAD,
and use remoting to access it, it would be a mistake
to assume that you can pass most objects exposed
by the wrappers across the wire (e.g., remote them
to another process). Even if you could, I would doubt
that you would want to, given the performance hit
that remoting imposes.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:5027202@discussion.autodesk.com...
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.
Message 13 of 16
Anonymous
in reply to: cctbailey

Thanks for catching that, I had only used this technique for plotting remotely in the past so I didn't notice that limitation. You can load acdbmgd.dll and acmgd.dll in a stand alone program, what you cannot do is instantiate objects. You would need to keep all of your AutoCAD specific code in the dll loaded in AutoCAD and just pass in parameters to create objects (end points of a line, center / radius of a circle, etc) then create the objects in AutoCAD.

You can still use this technique to automate AutoCAD from out of process, you just cannot pass AutoCAD specific objects across the process boundary.

As for whether or not you would want to, in my case I do but that's up to the individual application I suppose.
Message 14 of 16
Anonymous
in reply to: cctbailey

>> You can load acdbmgd.dll and acmgd.dll in a stand
>> alone program, what you cannot do is instantiate objects

No, you really can't load them into a stand-alone process.

The runtime does not actually load an assembly until the
first time you attempt to instantiate an object or reference
static data from the assembly, so if never do either of those
things, the assembly is never loaded.

Those assemblies can only be referenced from another
process, but not actually loaded.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
Message 15 of 16
Anonymous
in reply to: cctbailey

Got it. Thanks.
Message 16 of 16
cctbailey
in reply to: cctbailey

Guys,

Thanks so much for the responses. I understand basically what you guys are talking about, but I'm still very unclear on how to make it happen. I actually have posted my problem more specifically on another post (http://discussion.autodesk.com/thread.jspa?threadID=442254). Basically, I need to create an exe that will allow the user to select drawings that need to be plotted. The AutoCAD part is that the program needs to open AutoCAD, open the drawings, create plt files of each one, and then (if the user selects it), plot the drawing to either half or full size. I'm not actually trying to draw in AutoCAD, but I need to be able to access AutoCAD's plot functionality.

I have been asked to do this in VB .NET if at all possible, because "it is the wave of the fuutre".

I have found virtually no examples on how to do this, however there is one gentleman that posted to my other post who is writing a blog example at http:\\snippetsandmusings.blogspot.com, but any other code that would help would be greatly appreciated.

Thanks,
Christy

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost