Creating layout & logic AutoCAD plugin dialog

659 Views Asked by At

I am brand new to AutoCAD plugin development. I'm trying to create a plugin that loads as an entire main menu option inside of AutoCAD (let's call this menu the "Fizzbuzz" menu, and when the user selects one of the menu items (say, Fizzbuzz >> Foobar) I want a simple dialog/window to show up on screen in the top-left corner of AutoCAD.

I'm trying to figure out where the presentation/layout logic for this dialog/popup window needs to go (what file does it live in and how do I create/edit it?), and just as importantly: where the event-driven GUI logic needs to go (again: what file do I edit and in what language?). By "GUI logic" I mean: let's say there's a checkbox or button inside my dialog... when the user clicks/interacts with these UI components, I need custom logic to execute.

What files house this type of presentation/GUI logic for new AutoCAD plugins and how I create/edit them?

1

There are 1 best solutions below

0
On

I have added a palette hosting a winform control this way:

using System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Windows;

namespace AMU.AutoCAD.BlockTool
{
  public class MyPalette : IExtensionApplication
  {

  private PaletteSet palette;
  private Control paletteControl;

  public void Initialize()
  {
    //This is called when AutoCAD loads your assembly
    this.palette = new PaletteSet("Name")
    {
      TitleBarLocation = PaletteSetTitleBarLocation.Left,
      Style = PaletteSetStyles.Snappable //Your Styles
    };
    this.paletteControl = new Control(); //Instance of your Control that will be visible in AutoCAD
    this.palette.Add("HEADER", this.paletteControl);
    this.palette.Visible = true;

  }

  public void Terminate()
  {
    //cleanup
    this.palette.Dispose();
    this.paletteControl.Dispose();
  }
}
}

By providing a class implementing the IExtensionApplication you can execute custom code on loading a dll, without explicitly call a method. You now can create a so called PaletteSet and add a Winform or WPF Control to it.