.NET

Reply
*Expert Elite*
norman.yuan
Posts: 988
Registered: ‎04-27-2009
Message 11 of 12 (85 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: 76
Registered: ‎11-19-2010
Message 12 of 12 (83 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...
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.