muck Posted June 3, 2015 Posted June 3, 2015 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, Quote
Jeff H Posted June 3, 2015 Posted June 3, 2015 A simple way is to add a parameter in the constructor and pass it in. public AcadForm(Document acDoc ) { } Quote
muck Posted June 3, 2015 Author Posted June 3, 2015 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, Quote
BlackBox Posted June 3, 2015 Posted June 3, 2015 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. 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> Quote
Recommended Posts
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.