Through the Interface: Displaying a dialog on AutoCAD startup using .NET

May 2015

Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30


« Visualization of Autodesk’s organizational ebbs and flows | Main | Creating polyline boundaries from 2D AutoCAD solids using .NET »

January 09, 2013

Displaying a dialog on AutoCAD startup using .NET

This post is based on some information provided by Peter Muigg, a developer in Germany Austria who has long been a friend of Autodesk. In fact, if memory serves me well – and do step in if I’m mis-remembering, Peter – back in 1995 when I first joined the company, Peter delivered German-language ObjectARX training on behalf of Autodesk.

Peter reached out with this tip just before the holiday break: he needed to display a dialog on AutoCAD startup, but found that it was too soon to do so on IExtentionApplication.Initialize() (it’s assumed this module is either demand- or auto-loaded, by the way – manual loading doesn’t tend to exhibit this issue).

I typically use the approach of posting a command/queueing up a LISP expression to execute on startup to do this, but Peter has successfully used the Application.Idle event, instead.

Here’s Peter’s C# code:

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.Runtime;

using System;


public class App : IExtensionApplication


  static MyPalette _palette;


  public void Initialize()


    // ... other stuff


    // Create a hook on the "Idle" event of the application class


    Application.Idle += new EventHandler(Application_Idle);




  void Application_Idle(object sender, EventArgs e)


    // Remove the event handler as it is no longer needed


    Application.Idle -= Application_Idle;

    _palette = new MyPalette();

    _palette.Visible = true;



  // ...


The code itself shouldn't need any explanation – it's both simple and elegant. Thanks for sharing it, Peter!


Peter has since clarified he’s based in Innsbruck, so I’ve updated the post accordingly. My apologies for getting that wrong, especially being based in neighbouring Switzerland! :-(

blog comments powered by Disqus


10 Random Posts