.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to add a new menu in the main toolbar?

9 REPLIES 9
Reply
Message 1 of 10
dynamicscope
2349 Views, 9 Replies

How to add a new menu in the main toolbar?

Hello to all.

 

I'm new to ObjectARX (.NET).

I would like to add a customized menu in the main toolbar.

Can't find any sample in ObjectARX 2011 samples. And it's really hard to find references.

Could I get some help, please?

 

Thank you.

9 REPLIES 9
Message 2 of 10


@dynamicscope wrote:
...I would like to add a customized menu in the main toolbar...

What is "main toolbar"?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 10

Oh. I'm sorry. I meant the menubar where "File" "Edit" "View"... sutff placed.

Message 4 of 10

OK.

1. ObjectARX SDK: samples\dotNet\CuiSamp (but only ObjectARX SDK 2008 and 2009)

2. ActiveX-interface

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 10

Following C# (VS 2008) code is what I tried with ObjectARX 2011 SDK & AutoCAD 2011.

When I debug the code it seems it runs fine. It passes throught the if statement without any error.

But I can't find the newly added menu.

Is the code wrong?

 

        [CommandMethod("MyGroup", "My", "MyCommandLocal", CommandFlags.Modal)]
        public void MyCommand() // This method can have any name
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            CustomizationSection cs;
            string mainCuiFile = (string)Application.GetSystemVariable("MENUNAME");
            mainCuiFile += ".cuix";
            ed.WriteMessage(mainCuiFile);
            cs = new CustomizationSection(mainCuiFile);

            if (cs.MenuGroup.PopMenus.IsNameFree("Custom Menu"))
            {
                System.Collections.Specialized.StringCollection pmAliases = new System.Collections.Specialized.StringCollection();
                PopMenu pm = new PopMenu("Custom Menu", pmAliases, "Custom Menu Tag", cs.MenuGroup);

                PopMenuItem pmi = new PopMenuItem(pm, -1);
                pmi.MacroID = "ID_AUGI";
                pmi.Name = "Autodesk User Group International";
                pmi = new PopMenuItem(pm, -1);
                pmi = new PopMenuItem(pm, -1);
                pmi.MacroID = "ID_CustomSafe";
                pmi.Name = "Online Developer Center";

                foreach (Workspace wk in cs.Workspaces)
                {
                    WorkspacePopMenu wkpm = new WorkspacePopMenu(wk, pm);
                    wkpm.Display = 1;
                }
            }
            else
                ed.WriteMessage("Custom Menu already Exists\n");
}

 

Message 6 of 10

cs.Save();
string flName = cs.CUIFileBaseName;
Application.SetSystemVariable("FILEDIA",0);
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("_cuiunload " + flName + " ",false,false,false);
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("_cuiload " + flName + " filedia 1 ",false,false,false);


 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 7 of 10

If I add the following code, I see my newly added menu "Custom Menu" at the very end of list.

But still can't find it in the GUI menubar.

 

            foreach (Workspace wk in cs.Workspaces)
            {
                ed.WriteMessage(wk.Name);
                foreach (WorkspacePopMenu wsPM in wk.WorkspacePopMenus)
                {
                    PopMenu pm = cs.getPopMenu(wsPM.PopMenuID);
                    if (pm != null)
                    {
                        ed.WriteMessage(string.Format("\n{0}", pm.Name));
                    }
                }
            }

 

Thanks a lot for assisting me.

Message 8 of 10

Still doesn't show up. =(

Would there be any other approach?

Message 9 of 10

Try:

Application.DocumentManager.MdiActiveDocument.
SendStringToExecute("(menucmd \"Gacad.Help=+MyGroupName.MyPopUpMenuName\") ",false,false,false);

MyGroupName is a name of your's menugroup
MyPopUpMenuName is a name of your's popup-menu.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 10 of 10

Unfortunately, the code didn't work for me. 😞

However, I found the following link working.

 

http://through-the-interface.typepad.com/through_the_interface/2010/04/adding-to-autocads-applicatio...

 

The code block looks very similar to the one you taught me.

But I am not sure why only the code from the link works.

 

Anyway, I think my problem is finally solved.

 

Thank you a lot for your help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost