.NET

Reply
Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 1 of 10 (929 Views)

How to add a new menu in the main toolbar?

929 Views, 9 Replies
04-04-2012 12:27 AM

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.

Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 2 of 10 (918 Views)

Re: How to add a new menu in the main toolbar?

04-04-2012 03:29 AM in reply to: dynamicscope

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

What is "main toolbar"?


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 3 of 10 (915 Views)

Re: How to add a new menu in the main toolbar?

04-04-2012 04:02 AM in reply to: Alexander.Rivilis

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

Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 4 of 10 (911 Views)

Re: How to add a new menu in the main toolbar?

04-04-2012 04:37 AM in reply to: dynamicscope

OK.

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

2. ActiveX-interface


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 5 of 10 (889 Views)

Re: How to add a new menu in the main toolbar?

04-04-2012 06:03 PM in reply to: Alexander.Rivilis

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");
}

 

Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 6 of 10 (883 Views)

Re: How to add a new menu in the main toolbar?

04-04-2012 10:07 PM in reply to: dynamicscope
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);


 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 7 of 10 (873 Views)

Re: How to add a new menu in the main toolbar?

04-05-2012 02:30 AM in reply to: Alexander.Rivilis

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.

Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 8 of 10 (836 Views)

Re: How to add a new menu in the main toolbar?

04-10-2012 02:44 AM in reply to: Alexander.Rivilis

Still doesn't show up. =(

Would there be any other approach?

Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 9 of 10 (802 Views)

Re: How to add a new menu in the main toolbar?

04-16-2012 10:21 PM in reply to: dynamicscope

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.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 10 of 10 (770 Views)

Re: How to add a new menu in the main toolbar?

04-18-2012 02:05 AM in reply to: Alexander.Rivilis

Unfortunately, the code didn't work for me. :smileysad:

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.

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.