.NET

Reply
*Expert Elite*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 11 of 12 (88 Views)

Re: How a DWG is opened

09-17-2013 06:53 AM in reply to: StormyC

If you only want to run some code once on each drawing, you can hook up DoucmentActivated or DocumentBecameCurrent event when your IExtesionApplication assenbly is loaded on AutoCAD startup. Then, I'd use Document.UserData to flag it. Something like:

 

void DocumentBecameCurrent (....)

{

    bool processd=false;

    try

    {

        process=(bool)e.Document.UserData["MyDwgOpenProcess"];

    }

    catch{}

 

    if (!processed)

    {

        e.Document.UserData["MyDwgOpenProcess"]=true;

        e.Document.SendStringToExecute("MyCustomCommand "....)

    }

}

Valued Contributor
StormyC
Posts: 82
Registered: ‎11-19-2010
Message 12 of 12 (86 Views)

Re: How a DWG is opened

09-17-2013 07:15 AM in reply to: norman.yuan
Again many thanks for taking the time to reply.

I will try that out and post back, will not be for a while though...
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.