.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problem with constructor

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
nklong
590 Views, 4 Replies

problem with constructor

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!

4 REPLIES 4
Message 2 of 5
Hallex
in reply to: nklong

Try use

Autodesk.AutoCAD.ApplicationServices.Application

instead of Application

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 5
nklong
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.

Message 4 of 5
DiningPhilosopher
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.

Message 5 of 5
nklong
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);
        }

    }

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost