.NET

Reply
Valued Contributor
cjuliano
Posts: 50
Registered: ‎09-11-2005
Message 11 of 19 (56 Views)

Re: Easy Question

09-19-2005 12:38 PM 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?
Valued Contributor
cjuliano
Posts: 50
Registered: ‎09-11-2005
Message 12 of 19 (56 Views)

Re: Easy Question

09-20-2005 06:27 AM 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?
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 13 of 19 (56 Views)

Re: Easy Question

09-20-2005 06:57 AM 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)
Valued Contributor
cjuliano
Posts: 50
Registered: ‎09-11-2005
Message 14 of 19 (56 Views)

Re: Easy Question

09-20-2005 07:04 AM in reply to: cjuliano
Mikko - Thanks a bunch. That did it!!!!!!!!!!!!!!!!!!
Valued Contributor
cjuliano
Posts: 50
Registered: ‎09-11-2005
Message 15 of 19 (56 Views)

Re: Easy Question

09-20-2005 07:46 AM 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.
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 16 of 19 (56 Views)

Re: Easy Question

09-20-2005 08:49 AM 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
Valued Contributor
cjuliano
Posts: 50
Registered: ‎09-11-2005
Message 17 of 19 (56 Views)

Re: Easy Question

09-20-2005 08:58 AM 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.
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 18 of 19 (56 Views)

Re: Easy Question

09-20-2005 09:56 AM 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
Valued Contributor
cjuliano
Posts: 50
Registered: ‎09-11-2005
Message 19 of 19 (56 Views)

Re: Easy Question

09-20-2005 10:09 AM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community