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

DocumentManager.MdiActiveDocument

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
1468 Views, 2 Replies

DocumentManager.MdiActiveDocument

Can someone explain something to me?

I am trying to get the active document in AutoCAD using C#. To do this I am
using:

Document doc =
Autodesk.AutoCAD.ApplicationServices.DocumentManager.MdiActiveDocument;

To me this seems as if it should work as I am declaring the variable doc as
a Document and assigning it as the active document in AutoCAD. However when
I try to compile my code I get an error stating.

c:\Documents and Settings\TJRiley\My Documents\SharpDevelop
Projects\KSSetup\MainForm.cs(239,30): error CS0120: An object reference is
required for the nonstatic field, method, or property
'Autodesk.AutoCAD.ApplicationServices.DocumentManager.MdiActiveDocument'

Can someone please explain to me what this error message means?

Thanks,

Tim
2 REPLIES 2
Message 2 of 3
cgay
in reply to: Anonymous

Tim,

Hi, I think you need to get the document manager from the Application object, like this:
[code]
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
[/code]

Good Luck,
Clif
Message 3 of 3
Anonymous
in reply to: Anonymous

Doh...I can't believe I missed that.

Thank you very much.

Tim Riley

wrote in message news:4932513@discussion.autodesk.com...
Tim,

Hi, I think you need to get the document manager from the Application
object, like this:
[code]
Document doc =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
[/code]

Good Luck,
Clif

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