Author Topic: Populating custom drop-down in Ribbon panels  (Read 2576 times)

0 Members and 1 Guest are viewing this topic.

FOUAD ABOU RJEILY

  • Guest
Populating custom drop-down in Ribbon panels
« on: October 19, 2012, 08:59:07 AM »
Hello

Using the CUI interface of AutoCAD 2012 or using autolisp, how can I create a custom combo box and populate it with several values in a custom panel on the ribbon, similar for example to the LAYER selection drop-down on 'layers' panel of the 'Home' ribbon.

(Purpose: Let the engineer select which Discipline ie. Architecture, structural, Electrical,... he wants to work with, affecting the layers to be inserted when developing the drawings.)

Can somebody please direct me to proper help resources
Thank you


jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Populating custom drop-down in Ribbon panels
« Reply #1 on: October 19, 2012, 09:30:04 AM »
The only way to come close is to create a custom POP menu (think right-click menu) to be called from a tool button.  The menu will be displayed at the mouse so the interface will be close.  Do a search - I posted some code a very long while ago.  If you can't find anything let us know.  (There are many very competent folks around here).

And welcome to the Swamp!!

jb

Oh, and not to disappoint the rest of you: OpenDCL can create a really cool form that mimics OP's desired behavior exactly!!
 8-)
James Buzbee
Windows 8

BlackBox

  • King Gator
  • Posts: 3770
Re: Populating custom drop-down in Ribbon panels
« Reply #2 on: October 19, 2012, 09:44:43 AM »
FWIW -

I've always found DOSLib to be very useful, and precludes the need to learn DCL... Perhaps you'd find DOS_COMBOLIST to be of use?

Having said that, know that while useful, you're not going to get much customization out of it (DOSLib), as it tends to be cookie-cutter forms with some basic parameters to tailor (depending on the function).

If you need custom forms, then either use one of the adaptations of DCL, or hop into Visual Studio, and port your custom Form to a LispFunction Method (overkill for this, methinks - just wanted you to know that it is possible).

HTH
"How we think determines what we do, and what we do determines what we get."

laidbacklarry

  • Guest
Re: Populating custom drop-down in Ribbon panels
« Reply #3 on: October 19, 2012, 10:06:09 AM »
Ignore/forget the ribbon... it requires at least another 'pick' or more to get to the command you want... just another example of Autodesk's unfortunate (there are other words) alliance with M$... I'm leaning more and more to Bricscad

laidbacklarry

  • Guest
Re: Populating custom drop-down in Ribbon panels
« Reply #4 on: October 19, 2012, 10:14:36 AM »
Renderman - for what its worth, I've been able to whatever I wanted/needed to do for over 25 years in plain Alisp/DCL. And, be assured that my programs work in pretty much any variety of Intellicad, especially Briccscad. Does anyone really care about ACAD anymore????

BlackBox

  • King Gator
  • Posts: 3770
Re: Populating custom drop-down in Ribbon panels
« Reply #5 on: October 19, 2012, 10:30:44 AM »
Ignore/forget the ribbon... it requires at least another 'pick' or more to get to the command you want... just another example of Autodesk's unfortunate (there are other words) alliance with M$... I'm leaning more and more to Bricscad

I know that everyone has different hardware configurations (i.e. computer specs, monitor sizes, etc.), but I've never had an issue with the Ribbon... Except back in LDC 2009, which was not customizable to the user (until a service pack, etc.).

In any event, one could easily create a keyboard alias for this .NET CommandMethod, or add to a one-click mouse macro, etc. so you don't need to move your mouse up, down, or to the side, for the ribbon... You could even add a LispFunction if needed.

This code iterates the RibbonTabCollection to check... checks for the defined RibbonTab, and if it exists, sets it active. If the RibbonTab is not found, then the RibbonTab is created and set active.

Pseudo code:

Code - C#: [Select]
  1.  
  2. using Autodesk.AutoCAD.ApplicationServices;
  3. using Autodesk.AutoCAD.DatabaseServices;
  4. using Autodesk.AutoCAD.EditorInput;
  5. using Autodesk.AutoCAD.Runtime;
  6. using Autodesk.Windows;
  7.  
  8. using System;
  9.  
  10. // This line is not mandatory, but improves loading performances
  11. [assembly: CommandClass(typeof(FOO.MyCommands))]
  12.  
  13. namespace FOO
  14. {
  15.     public class MyCommands
  16.     {
  17.  
  18.         private Editor ed =
  19.             Application.DocumentManager.MdiActiveDocument.Editor;
  20.  
  21.         // Jeff_M is awesome:
  22.         // http://www.theswamp.org/index.php?topic=32869.msg383525#msg383525
  23.  
  24.         [CommandMethod("DOCRIB")]
  25.         public void DOCRIBCMD()
  26.         {
  27.             // Define ribbon properties
  28.             String myTabId = "DOCTAB";
  29.             String myTabTitle = "Document";
  30.             Boolean myTabIsContextual = true;
  31.  
  32.             try
  33.             {
  34.                 RibbonControl oRibbon = ComponentManager.Ribbon;
  35.                 if (oRibbon != null)
  36.                 {
  37.                     RibbonTab oTab = oRibbon.FindTab(myTabId);
  38.                     if (oTab != null)
  39.                     {
  40.                         oTab.IsActive = true;
  41.                     }
  42.                     else
  43.                     {
  44.                         oTab = new RibbonTab();
  45.                         oTab.Title = myTabTitle;
  46.                         oTab.Id = myTabId;
  47.                         oTab.IsContextualTab = myTabIsContextual;
  48.                         oTab.IsVisible = true;
  49.  
  50.                         oRibbon.Tabs.Add(oTab);
  51.  
  52.                         oTab.IsActive = true;
  53.  
  54.                         // <-- Add your ribbon panel(s) here
  55.  
  56.                     }
  57.                 }
  58.             }
  59.  
  60.             catch (Autodesk.AutoCAD.Runtime.Exception ex)
  61.             {
  62.                 ed.WriteMessage("\n** Error: " + ex.Message + " ** ");
  63.             }
  64.         }
  65.     }
  66. }
  67.  



Renderman - for what its worth, I've been able to whatever I wanted/needed to do for over 25 years in plain Alisp/DCL. And, be assured that my programs work in pretty much any variety of Intellicad, especially Briccscad. Does anyone really care about ACAD anymore????

I suggested DOSLib, as it may help someone who does not know how to code DCL, nothing more.
"How we think determines what we do, and what we do determines what we get."