.NET

Reply
Contributor
phil
Posts: 16
Registered: ‎06-24-2010
Message 1 of 5 (723 Views)

GetAcadDocument

723 Views, 4 Replies
03-28-2012 04:31 PM

I'm having trouble trying to get the GetAcadDocument method to work.

 

2012 code:

ThisDrawing = DocumentManager.MdiActiveDocument.AcadDocument

 

2013:

ThisDrawing = DocumentExtension.GetAcadDocument(Application.DocumentManager.MdiActiveDocument)

 

Produces a run time error.  I know just enough .net to brute force my app to do what I want and would appreciate any help.

 

Thanks,

Phil

*Expert Elite*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 2 of 5 (705 Views)

Re: GetAcadDocument

03-28-2012 11:29 PM in reply to: phil

Hi,

 

for me it's running (it used time to find the alternative to .AcadDocument but with the method same to yours it's working for me. How is ThisDrawing declared at your code, what runtime-error do you get exactly?

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
phil
Posts: 16
Registered: ‎06-24-2010
Message 3 of 5 (686 Views)

Re: GetAcadDocument

03-29-2012 08:44 AM in reply to: Alfred.NESWADBA

Thanks for the response Alfred...confirming the code was ok made me look for a more fundamental problem and I realized I had a bad reference.

Active Member
jrenatto
Posts: 8
Registered: ‎07-22-2013
Message 4 of 5 (316 Views)

Re: GetAcadDocument

07-26-2013 08:25 AM in reply to: phil

Greetings, I have the same problem you had, I would like you to help me solve mine, with some questions
. How did you fix it?
- Versiond and vb.net What did you use?
- What version of AutoCAD are you?
- What references did you use?

I await your reply, thanks.

*Expert Elite*
_gile
Posts: 2,085
Registered: ‎04-29-2006
Message 5 of 5 (283 Views)

Re: GetAcadDocument

07-28-2013 03:50 AM in reply to: jrenatto

Hi,

 

Just a little precision about GetAcadDocument() method.

 

It's an extension method which extents the Document type (defining extension isn't exactly the same with C# or VB).

 

Extension methods can be called both way (assuming doc = MdiActivedocument):

 

- as static (Shared) methods as shown upper:

ThisDrawing = DocumentExension.GetAcadDocument(doc)

 

- as instance methods of the extended type:

ThisDrawing = doc.GetAcadDocument():

 

The second one will directly work with C# because DocumentExtension is a class of the ApplicationServices namespace.

But with VB extension methods have to be defined in a Module, so, the DocumentExtension module have to be imported for this behavior to be available.

Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension

Gilles Chanteau
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 or visit the Installation and Licensing Forum to get help installing your software.