.NET

Reply
Active Member
nklong
Posts: 10
Registered: ‎05-10-2012
Message 1 of 5 (304 Views)
Accepted Solution

problem with constructor

304 Views, 4 Replies
05-23-2013 09:57 PM

I want to inform user the name of command immediately when they netload my dll. I use the constructor like this way:

 

public class Control
    {
        public Control()
        {
            Editor acDoc = Application.DocumentManager.MdiActiveDocument.Editor;
            acDoc.WriteMessage("Type ABC to start");
        }

        [CommandMethod("abc", CommandFlags.UsePickSet)]
        public void MyForm_start()
        {
            MyForm fr = new MyForm();
            Application.ShowModalDialog(fr);
        }

    }

 

But it only write to command line when call abc command. Pls help!

The class that contains your command methods is not constructed until the first time one of the commands is used.

 

You have to use IExtensionApplication.Initialize() to display a message when your assembly is Netloaded.

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 5 (288 Views)

Re: problem with constructor

05-24-2013 12:15 AM in reply to: nklong

Try use

Autodesk.AutoCAD.ApplicationServices.Application

instead of Application

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Active Member
nklong
Posts: 10
Registered: ‎05-10-2012
Message 3 of 5 (282 Views)

Re: problem with constructor

05-24-2013 01:00 AM in reply to: nklong

Thank you, but it's still not right. I need after user call 'netload' and select my dll file. it will show some information to autocad command line.

Thank again.

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 4 of 5 (266 Views)

Re: problem with constructor

05-24-2013 04:25 AM in reply to: nklong

The class that contains your command methods is not constructed until the first time one of the commands is used.

 

You have to use IExtensionApplication.Initialize() to display a message when your assembly is Netloaded.

Active Member
nklong
Posts: 10
Registered: ‎05-10-2012
Message 5 of 5 (255 Views)

Re: problem with constructor

05-24-2013 08:39 AM in reply to: nklong

Thank you so much. I can do it already.

 

    public class Control : Autodesk.AutoCAD.Runtime.IExtensionApplication
    {        
        public void Initialize()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage("Type ABC to start.");
        }

        public void Terminate()
        {
            Console.WriteLine("Cleaning up...");
        }

        [CommandMethod("abc", CommandFlags.UsePickSet)]
        public void MyForm_start()
        {
            MyForm fr = new MyForm();
            Application.ShowModalDialog(fr);
        }

    }

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!