• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Valued Contributor
    Posts: 63
    Registered: ‎04-04-2012

    How to add a new menu in the main toolbar?

    546 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.

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,168
    Registered: ‎04-09-2008

    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

    Please use plain text.
    Valued Contributor
    Posts: 63
    Registered: ‎04-04-2012

    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.

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,168
    Registered: ‎04-09-2008

    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

    Please use plain text.
    Valued Contributor
    Posts: 63
    Registered: ‎04-04-2012

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

     

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,168
    Registered: ‎04-09-2008

    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

    Please use plain text.
    Valued Contributor
    Posts: 63
    Registered: ‎04-04-2012

    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.

    Please use plain text.
    Valued Contributor
    Posts: 63
    Registered: ‎04-04-2012

    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?

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,168
    Registered: ‎04-09-2008

    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

    Please use plain text.
    Valued Contributor
    Posts: 63
    Registered: ‎04-04-2012

    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.

    Please use plain text.