Ribbon Elements sample code and reproducing

Ribbon Elements sample code and reproducing

1479892004
Community Visitor Community Visitor
1,571 Views
3 Replies
Message 1 of 4

Ribbon Elements sample code and reproducing

1479892004
Community Visitor
Community Visitor

I  am tring  to reproduce the sample code in

 Customize User Interface (CUI) Managed API (.NET)  at Ribbon Elements (.NET)

,But  some prblom like

 

CODE 1:

 

***

RibbonButton button1 = new RibbonButton();//RibbonButton in Autodesk.Windows   (adwindows.dll)
button1.text = “button1”;//I have no  see  the string property in the RibbonButton class

***

 

CODE 2:

 

***

RibbonRow row = new RibbonRow();//RibbonRow not in Autodesk.Windows (adwindows.dll)
row.RowItems.Add(button1);// If use Autodesk.AutoCAD.Customization namespace(may be in acui.dll)
row.RowItems.Add(button2);//not have the property call “RowItems”

***

 

CODE 3:

 

***

RibbonPanelSource panelSource = new RibbonPanelSource();
panelSource.Title = "Panel1";
panelSource.Rows.Add(row);//not have the property call “Row”

***

 

The developer’s document writed the Ribbon Element ‘s interface in Autodesk.Windows(adwindows.dll)

 

How to solve it?

thank you

——————————————————————————————————————————————————————————————————————————————

CODE 在上面贴出了,不知道为什么复现不了样例代码。

RibbonButton类我也没看懂这个Text属性哪里来的,

RibbonRow类也不在Autodesk.Windows 命名空间里面,

RibbonPanelSource的类内部属性也没有Row这个属性。

非常感谢解答!

0 Likes
1,572 Views
3 Replies
Replies (3)
Message 2 of 4

Norman_Yuan
Mentor
Mentor

There are 2 sets of ribbon related APIS: one is in Autodesk.AutoCAD.Customiztion namespace of the assembly acCui.dll, the other is in Autodesk.Windows namespace of the assembly adWindows.dll.

 

When you say you try to "reproduce the sample code...", you need to know which set of API the sample code uses.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 4

1479892004
Community Visitor
Community Visitor

Thank you very much for your reminding!

I tried to improve the sample code to run under the Autodesk.Windows namespace of Adwindows.dll.

I replaced the old class RibbonRow with the RibbonRowPanel class. I tried to initialize the ribbon element, but it didn't work.

There are no warning and compile fails

CODE:

 

using Autodesk.Windows;

*****

public class adskClass : IExtensionApplication
{
       public void Initialize()
   {
            RibbonButton button1 = new RibbonButton
       {
            Text = "Button1"
       };
            RibbonButton button2 = new RibbonButton
       {
            Text = "Button2"
       };
            RibbonRowPanel E = new RibbonRowPanel
       {
            Items = {button1, button2}
       };
            RibbonPanelSource panelSource = new RibbonPanelSource
      {
            Title = "Panel1"
      };
            panelSource.Items.Add(E);
            RibbonPanel panel = new RibbonPanel
      {
            Source = panelSource
      };
            RibbonTab tab = new RibbonTab
      {
            Title = "Tab1"
      };
            tab.Panels.Add(panel);
            RibbonControl ribbon = new RibbonControl();
            ribbon.Tabs.Add(tab);

}

 

What should I do to add Ribbon ?

 

*****************************************************************************

非常感谢您的提醒
我尝试改进了示例代码使之能够在Adwindows.dll 的 Autodesk.Windows 命名空间下运行。
我用RibbonRowPanel类 替换了原来的老 class RibbonRow。我尝试初始化加载此ribbon element ,但是没有正常工作。

我应该怎么做才能正常的添加Ribbon?

0 Likes
Message 4 of 4

Norman_Yuan
Mentor
Mentor

OK, it looks like you want to create a custom ribbon tab with code and loaded when your DLL is loaded.

This topic has been discussed here many times. Please search this forum for "Ribbon", you will find quite a few past discussion threads with code in them, such as:

 

https://forums.autodesk.com/t5/net/custom-menu-and-ribbon-with-code/m-p/10511529 

https://forums.autodesk.com/t5/net/net-c-ribbon-tab/m-p/3920030 

https://forums.autodesk.com/t5/net/ribbon-not-loading-on-autocad-2024/m-p/12130528 

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes