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

Easy Question

18 REPLIES 18
Reply
Message 1 of 19
cjuliano
613 Views, 18 Replies

Easy Question

Can vb.net be used with AutoCAD 2004?
18 REPLIES 18
Message 2 of 19
Anonymous
in reply to: cjuliano


No, it can't. AutoCAD 2005 is the first release
supporting .NET via ObjectARX set of managed functions. I'm suggesting using
AutoCAD 2006 to develop .NET apps.

 

Can vb.net be used with AutoCAD
2004?
Message 3 of 19
cjuliano
in reply to: cjuliano

So basically I can even get AutoCAD to launch and open a drawing? If that is the case then upgrading is coming much sooner than I thought.

Thanks
Message 4 of 19
Anonymous
in reply to: cjuliano


Starting ACAD 2004 can be done out of
VB.NET, but you don't need VB.NET to achieve this (any VB will do) 🙂 Managed
set of functions exposed by ObjectARX 2005 and higher let you manipulate ACAD
objects in "ObjectARX way", plus Framework functionality.

 

So basically I can even get
AutoCAD to launch and open a drawing?  If that is the case then upgrading
is coming much sooner than I thought.

Thanks
Message 5 of 19
cjuliano
in reply to: cjuliano

At this point in time I am just working with a drawing manager program so all I need to do is open an AutoCAD drawing using VB.Net.

I have been toying around with it a bit and haven't had much success in starting ACAD or opening my drawing. Are there code examples somewhere?


Thanks for the help.
Message 6 of 19
Anonymous
in reply to: cjuliano

Just search down this NG for examples (plenty of them, in fact).

wrote in message news:4960481@discussion.autodesk.com...
At this point in time I am just working with a drawing manager program so
all I need to do is open an AutoCAD drawing using VB.Net.

I have been toying around with it a bit and haven't had much success in
starting ACAD or opening my drawing. Are there code examples somewhere?


Thanks for the help.
Message 7 of 19
Anonymous
in reply to: cjuliano

Check out the .NET programming section of our site. All of the articles on
the site are older and deal with using .NET and AutoCAD's COM API. While
some of the details in them are not true for newer versions, the basics of
them all still hold true. Have a look at the Getting Connected article to
see how to use .NET to open AutoCAD.
--
Bobby C. Jones
http://www.acadx.com

wrote in message news:4960417@discussion.autodesk.com...
Can vb.net be used with AutoCAD 2004?
Message 8 of 19
cjuliano
in reply to: cjuliano

Bobby,

A great deal of the links on "your" site don't go anywhere. I did manage to find the Getting Connected article. Since it is in #C how do I compile it for use in VB.Net???

I'll read through the article as well as check out the rest of this NG so hopefully I can find what I am looking for.

Thanks again.
Message 9 of 19
Anonymous
in reply to: cjuliano

When I have a moment where I'm not working on AU classes, I'm going to take
a look at that.

--
R. Robert Bell


wrote in message news:4960521@discussion.autodesk.com...
Bobby,

A great deal of the links on "your" site don't go anywhere. I did manage to
find the Getting Connected article. Since it is in #C how do I compile it
for use in VB.Net???

I'll read through the article as well as check out the rest of this NG so
hopefully I can find what I am looking for.

Thanks again.
Message 10 of 19
Anonymous
in reply to: cjuliano


Quck helper (late binding):

 

Dim myApp As Object
myApp
= CreateObject("AutoCAD.Application")
myApp.Visible = True

 


On the other hand, you may check
href="http://discussion.autodesk.com/forum.jspa?forumID=33">http://discussion.autodesk.com/forum.js...
,
most of the posts refer to what Bobby implied.

 

Regards,

Maksim Sestic

 

 

 

Bobby,

A great deal of
the links on "your" site don't go anywhere.  I did manage to find the
Getting Connected article.  Since it is in #C how do I compile it for use
in VB.Net???

I'll read through the article as well as check out the rest
of this NG so hopefully I can find what I am looking for.

Thanks
again.
Message 11 of 19
cjuliano
in reply to: cjuliano

I'll check out the post in a moment, thanks. I had seen the late binding as you put it and had that in my code and it worked fine. Now the only issue I have is loading the autocad drawing.

I'm using the code:

acadDoc.Open(FoundDrawingRecord, )

and this keeps throwing some type of exception. Can you explain what the heck I'm doing wrong?
Message 12 of 19
cjuliano
in reply to: cjuliano

As my own follow up to this post I checked the error code that was being generated. The error is #91 and the error description is the following:

"Object reference not set to an instance of an object"

Any help on this one?
Message 13 of 19
Mikko
in reply to: cjuliano

Did you set a reference to the active document?

Dim acadDoc As AutoCAD.AcadDocument
acadDoc = ACADApp.ActiveDocument
acadDoc.Application.Documents.Open(FoundDrawingRecord)
Message 14 of 19
cjuliano
in reply to: cjuliano

Mikko - Thanks a bunch. That did it!!!!!!!!!!!!!!!!!!
Message 15 of 19
cjuliano
in reply to: cjuliano

Another question...sorry guys. The last post from Mikko got me up and running as long as I have a drawing open. Waht would I do if I had AutoCAD open but no drawing open?

Thanks again.
Message 16 of 19
Mikko
in reply to: cjuliano

By default AutoCAD starts with a drawing open so you should always have some drawing on your screen. If the user shuts the drawing and your looking at an empty application you could just shut down that AutoCAD application and start a new one with the default drawing on the screen, something like this. I don't know if you can start a new drawing in an empty acad app. Never had to try. Somebody else might have a more viable solution.

Public WithEvents ACADApp As AutoCAD.AcadApplication
Dim acadDoc As AutoCAD.AcadDocument

Sub GetAcadApplication()
Try
ACADApp = GetObject(, "AutoCAD.Application.16")
ACADApp.Visible = True
Catch
MsgBox("Can't find AutoCAD so I'll try starting a new copy.")
Try
ACADApp = CreateObject("AutoCAD.Application.16")
ACADApp.Visible = True
Catch
MsgBox("Big Big Problem" + vbCrLf + "Closing down.", MsgBoxStyle.Critical)
End
End Try
End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GetAcadApplication()
Try
acadDoc = ACADApp.ActiveDocument
Catch
ACADApp.Quit()
GetAcadApplication()
acadDoc = ACADApp.ActiveDocument
End Try
acadDoc.Application.Documents.Open("c:/temp/test.dwg")
End Sub
Message 17 of 19
cjuliano
in reply to: cjuliano

Thanks Mikko,

What you have provided is a work around I can use for now, but shutting down AutoCAD and restarting seems to be a waste.

Thanks again for all your help.
Message 18 of 19
Mikko
in reply to: cjuliano

Here is what you are looking for I think.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GetAcadApplication()
Try
acadDoc = ACADApp.ActiveDocument
Catch
ACADApp.Documents.Add()
acadDoc = ACADApp.ActiveDocument
End Try
acadDoc.Application.Documents.Open("c:/temp/test.dwg")
End Sub
Message 19 of 19
cjuliano
in reply to: cjuliano

Thanks Mikko.

I had just figured out pretty much the same solution when my email notification went off. Again thanks for all the help.

Cujo

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