Jump to content

Recommended Posts

Posted

I have the statement.

 

Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

in a form routine.

 

I would like to be able to use acDoc in all my form routines. How do I make acDoc usable within my form?

 

Thank you,

Posted

A simple way is to add a parameter in the constructor and pass it in.

 

 

public AcadForm(Document acDoc )

{

 

 

}

Posted

Could you give me a better more complete example?

I am somewhat new to this. I don't even know what a constructor is?

Thank you,

Posted
Could you give me a better more complete example?

I am somewhat new to this. I don't even know what a constructor is?

 

More complete examples often follow the posting of the code you're having trouble with. :thumbsup:

 

 

 

Your plug-in exists within a Namespace, which implements Classes (aka Types), which provide Properties, Methods, and Events. A Constructor 'builds' or instantiates an instance of the Class (Type), and can be Overloaded (provide more than one Method, each accepting a different set of parameter, if any at all).

 

Since you didn't post code, I can only speculate that you call your Form within a particular Method, simply add a Form Constructor, which accepts 'Document acDoc' as parameter within your Form's Class, and then pass it along:

 

Pseudo-code:

// <snip>

Document acDoc = acDocs.MdiActiveDocument;

MyForm myForm = new MyForm(acDoc);

//<-- do something useful

// <snip>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...