MediaWiki:Cancel

From askoh.net wiki

Jump to: navigation, search

Boon Keat: Document your work here.

i will just add in all the codes that load the palette set and dialog.

palette set interface,


///////////////////////////////////////////////////////////


using System; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.Interop; using Autodesk.AutoCAD.Windows; using Autodesk.AutoCAD.ApplicationServices;


namespace AddonC {

   public class CreatePalette     
   {
       private PaletteSet ps;
       [CommandMethod("Cre")]
       public void Cre()
       {
           ps = new Autodesk.AutoCAD.Windows.PaletteSet("Motion Explorer");
           ps.MinimumSize = new System.Drawing.Size(300, 300);
           System.Windows.Forms.UserControl treeview = new ModelessForm();
           ps.Add("test", treeview);
           ps.Visible = true;
       }
   }

}

///////////////////////////////////////////////// creating this palette by typing the command the command "Create"

dialog type /////////////////////////////////////////////////


using System; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Windows;

namespace DialogBox {

   public class Dialogboxconfig
   {
       [CommandMethod("DialogBox")]
       public void DialogBox()
       {
           Dialog Modal = new Dialog();
           Application.ShowModalDialog(Modal);
       }
   }

} ///////////////////////////////////////////////// create the dialog box by typing dialogbox

To perform load-time initialization, we must implement a specific class to allow this. To do this the class needs to implement the IExtensionApplication .NET interface and expose an assembly-level attribute which specifies this class as the ExtensionApplication. The class can then respond to one-time load and unload events.

example:


[assembly: ExtensionApplication(typeof(test.testClass))] class testClass : IExtensionApplication { public void Initialize() {

      testAddMenu();

} }


}


UPDATED this part is the whole thing that links together

this is the the code to create a CUIX file for the main menu ////////////////////////////////////////////////////////////////////

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.Customization; using System.Collections.Specialized;


namespace MotionAddon {

   class CUIMenu
   {
       public static void CUI_menu()
       {
           const string MA_CuiFile = "c:\\Motion.cuix";
           const string MA_CuiFileToSend = "c:/Motion.cuix";
           const string MA_CuiSectionName = "Motion";
           string mainCui = Application.GetSystemVariable("MENUNAME") + ".cuix";
           CustomizationSection Main_CUI = new CustomizationSection(mainCui);
           PartialCuiFileCollection pcfc = Main_CUI.PartialCuiFiles;
           Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
           if (pcfc.Contains(MA_CuiFile))
           {
               ed.WriteMessage("\nMotion Addon CUI \"" + MA_CuiFile + "\" already loaded.");
           }
           else
           {
               if (System.IO.File.Exists(MA_CuiFile))
               {
                   ed.WriteMessage("\nMotion Addon CUI \"" + MA_CuiFile + "\" exists - loading it.");
               }
               else
               {
                   ed.WriteMessage("\nMotion Addon CUI \"" + MA_CuiFile + "\" does not exist - building it.");
                   CustomizationSection CusSec = new CustomizationSection();
                   CusSec.MenuGroupName = MA_CuiSectionName;
                   MacroGroup mg = new MacroGroup(MA_CuiSectionName, CusSec.MenuGroup);
                   MenuMacro mm1 = new MenuMacro(mg, "LoadExplorer", "CreateExplorer", "ID_Load");
                   MenuMacro mm2 = new MenuMacro(mg, "Simulation", "Simulation", "ID_Simulation");
                   ed.WriteMessage("\nWritting Code......");
                   StringCollection sc = new StringCollection();
                   sc.Add("POP15");
                   PopMenu pm = new PopMenu(MA_CuiSectionName, sc, "ID_POP", CusSec.MenuGroup);
                   PopMenuItem pmi1 = new PopMenuItem(mm1, "Motion Explorer", pm, -1);
                   PopMenuItem pmi2 = new PopMenuItem(mm2, "Simulation", pm, -1);
                   ed.WriteMessage("\nSaving File......");
                   System.IO.Directory.CreateDirectory(@"C:\Motion");
                   CusSec.SaveAs(MA_CuiFile);
                   ed.WriteMessage("\nFile Saved");
               }
           }
     
       }       
   }

} //////////////////////////////////////////////////////////////////




to auto run the dll on netload we have to use the IExtension thing

/////////////////////////////////////////////////////////////////

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.AutoCAD.Windows; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime;

[assembly: ExtensionApplication(typeof(MotionAddon.AddMotionMenu))]

namespace MotionAddon {

   public class AddMotionMenu : IExtensionApplication
   {
       public void Initialize()
       {
           CreateMenu();
           CUIMenu.CUI_menu();
           MotionInterface.CreateExplorer();
       }
       public void Terminate()
       {
       }
       void Click_Explorer(object Sender, EventArgs e)
       {
           MotionInterface.CreateExplorer(); 
       }
       void Click_Simulator(object Sender, EventArgs e)
       {
           //MotionInterface.CreateSimulator();
       }
   ContextMenuExtension addon_menu;
   void CreateMenu()
   {
       try
       {
           addon_menu = new ContextMenuExtension();
           addon_menu.Title = "Motion";
           MenuItem mi_1 = new MenuItem("Motion Explorer");
           MenuItem mi_2 = new MenuItem("Enable Simulator");
           addon_menu.MenuItems.Add(mi_1);
           addon_menu.MenuItems.Add(mi_2);
           mi_1.Click += new EventHandler(Click_Explorer);
           mi_2.Click += new EventHandler(Click_Simulator);
           Application.AddDefaultContextMenuExtension(addon_menu);
       }
       catch
       {
       }
   }
   }

}

//////////////////////////////////////////////////////////////////////



this is how i create all the explorer and dialog


///////////////////////////////////////////////////////////////////////


using System; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.AutoCAD.Windows; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime;

namespace MotionAddon {

   public class MotionInterface
   {
       static PaletteSet ps;
       [CommandMethod("CreateExplorer")]
       public static void CreateExplorer()
       {
           ps = new PaletteSet("Motion Explorer");
           ps.MinimumSize = new System.Drawing.Size(170,400);
           System.Windows.Forms.UserControl m_e = new MotionExplorer();
           ps.Add("Motion", m_e);
           ps.Visible = true;
       }
       public static void CreateSimulationBox()
       {
           SimulationDialog Dialog = new SimulationDialog();
           Application.ShowModalDialog(Dialog);
       }


   }

}

////////////////////////////////////////////////////////////////////////

Personal tools
Navigation