.NET

Reply
*Expert Elite*
Posts: 893
Registered: ‎04-27-2009
Message 11 of 12 (62 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: 60
Registered: ‎11-19-2010
Message 12 of 12 (60 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...

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community