Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MessageBox from inside a C# Inventor plugin

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
oransen
466 Views, 4 Replies

MessageBox from inside a C# Inventor plugin

A simple question, in here I'd like to show a message box...

        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;

            // ********************************  
            // how to put a message box here?
            // ********************************  

        }

 

...I've tried using the normal Forms.MessageBox.Show stuff but it does not exist in this context. Is there a native Inventor message box function?

 

Tags (2)
4 REPLIES 4
Message 2 of 5
JhoelForshav
in reply to: oransen

Hi @oransen 

Have you tried adding a reference to System.Windows.Forms in your project? 🙂

Message 3 of 5
oransen
in reply to: JhoelForshav

That does not seem to be available, only Input and Markup

 

oransen_0-1629287679845.png

 

...and...

 

oransen_1-1629287727938.png

 

I wonder what I am missing....

 

 

 

Message 4 of 5
JhoelForshav
in reply to: oransen

Hi @oransen 

You need to add it to your references in your Visual Studio project.

references.PNG

Right-click references in your project and add reference. It should be in a path like:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Windows.Forms.dll

Depending on your .NET-framework.

Message 5 of 5
Michael.Navara
in reply to: oransen

@JhoelForshav  you are right. But usually you need reference to System.Drawing too.

When you insert new form to your project, all required references are added automatically. Unwanted Form1 can be deleted.

 

@oransen You can use build-in "message box" inventorApp.CommandManager.PromptMessage(...), but its usage is little bit obscure. See API reference for more information.

Advantage of this is when Inventor is in silent mode, this PromptMessage is not displayed and don't block application.

When you use MessageBox, this is displayed always and user MUST close them. This may be a trouble when you run some automatic task without user interaction.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report