Code Red => .NET => Topic started by: daboho on August 28, 2021, 01:46:44 PM

Title: MY TAB/Ribbon not Show Permanent In Autocad
Post by: daboho on August 28, 2021, 01:46:44 PM
this code is run as well but problem while closed autocad ,my tab not permanent in autocad must every open autocad run TAB,Panel, and Button
how to edit for permanent tab in Autocad without every time open Run This Code to make TAB
thanks for attention
Code: [Select]
        public void Testme()
            RibbonControl ribbon = ComponentManager.Ribbon;
            if (ribbon != null)
                RibbonTab rtab = ribbon.FindTab("TEST ME");
                if (rtab != null)
                rtab = new RibbonTab();
                rtab.Title = "TEST  ME";
                rtab.Id = "Testing";
                //Add the Tab

        static void addContent(RibbonTab rtab)

        static RibbonPanel AddOnePanel()
            Document dwg = Application.DocumentManager.MdiActiveDocument;
            RibbonButton rb;
            RibbonPanelSource rps = new RibbonPanelSource();
            rps.Title = "Test One";
            RibbonPanel rp = new RibbonPanel();
            rp.Source = rps;

            //Create a Command Item that the Dialog Launcher can use,
            // for this test it is just a place holder.
            RibbonButton rci = new RibbonButton();
            rci.Name = "TestCommand";

            //assign the Command Item to the DialgLauncher which auto-enables
            // the little button at the lower right of a Panel
            rps.DialogLauncher = rci;

            rb = new RibbonButton();
            rb.Name = "Test Button";
            rb.ShowText = true;
            rb.ShowImage = true;
            rb.Width = 250;
            rb.Text = "Test Button";
            rb.CommandHandler = new MyRibbonCommandHandler();
            rb.CommandParameter = "CF";
          //  dwg.SendStringToExecute((string)rb.CommandParameter + " ", true, false, true);
            //Add the Button to the Tab
            return rp;



    internal class MyRibbonCommandHandler : System.Windows.Input.ICommand
        public event EventHandler CanExecuteChanged;

        public bool CanExecute(object parameter)
            return true;

        public void Execute(object parameter)
            RibbonCommandItem btn = parameter as RibbonCommandItem;
            if (btn != null)
                //execute an AutoCAD command, or your custom command defined by [CommandMethod]
                Document dwg = acApp.DocumentManager.MdiActiveDocument;
                dwg.SendStringToExecute((string)btn.CommandParameter + " ", true, false, true);


Title: Re: MY TAB/Ribbon not Show Permanent In Autocad
Post by: Keith™ on August 29, 2021, 10:49:40 PM
In your main class instantiation
Code - C#: [Select]
  1. public class MyAppClass{
  2.      ribbonClass myribbon = new ribbonClass(); //instantiate your ribbon class as necessary
  3. }

When you load your application into AutoCAD (netload) let that application load the ribbon for you.

Now, if you are loading the application and having it run when you load it, change that behavior such that you register commands in AutoCAD that execute your program as needed, but have the main class when loaded, instantiate your ribbon so it will always be available when AutoCAD is open.

You can auto netload an application by adding a setting in the registry:
Open the registry and browse to the relevant HKLM registry key ...
HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R19.1\ACAD-D000:407\Applications\ (this may be different in your installation)
Add the following keys and values:
LOADER (string) "path_to_your_dll"
DESCRIPTION (string) "Description of your application"
LOADCTRLS (dword) 0000000e
MANAGED (dword) 00000001

Once you do this, you need to restart AutoCAD.

You may need to netload the DLL at least once before the settings work, or they may work right away.

There are other ways to do this. For more information about automatically loading your .net assembly see this:

Title: Re: MY TAB/Ribbon not Show Permanent In Autocad
Post by: daboho on October 13, 2021, 05:44:32 PM
@keith thanks
Title: Re: MY TAB/Ribbon not Show Permanent In Autocad
Post by: Keith™ on October 18, 2021, 08:38:51 PM
No problem. This is how I solved my issue with the same.