Programmatically create Custom Toolbar to hold Custom Extensions - VB.NET

Programmatically create Custom Toolbar to hold Custom Extensions - VB.NET

Anonymous
Not applicable
1,522 Views
3 Replies
Message 1 of 4

Programmatically create Custom Toolbar to hold Custom Extensions - VB.NET

Anonymous
Not applicable

I am attempting to create a toolbar programmatically that will store command items to launch functions in our custom extensions through vb.net. I've read through the SDK and found the "CommandSiteLocationConstructor", but when using it I've run into an error I can't find a solution for. I've attempted the following code:

Dim testToolbarCmdSiteLoc As CommandSiteLocation = New CommandSiteLocation("test", CommandSiteLocationType.Toolbar)
Dim toolbarCmdSite As New CommandSite("TestCommand.Toolbar", "Add New TestCommand Menu")
toolbarCmdSite.DeployAsPulldownMenu = False
toolbarCmdSite.Location = testToolbarCmdSiteLoc
toolbarCmdSite.AddCommand(AddNewTestitem)

 

But on the first line where "CommandSiteLocationType.Toolbar" is the following error occurs:

Autodesk.Connectivity.Extensibility.Framework.ExtensionException: 'Invalid CommandSiteLocationType' at
Autodesk.Connectivity.Explorer.Extensibility.CommandSiteLocation..ctor(String customEntityName, CommandSiteLocationType type) at
.....
ErrorCodeEnum: IllegalInputParam

I haven't been able to find anyone who has run into this error and the "CommandSiteLocationType" is a valid enum in the SDK, so I'm not sure what's invalid about it. I've also tried putting the number equivalent, but the same error occurs. Any help would be appreciated. Thanks!

1,523 Views
3 Replies
Replies (3)
Message 2 of 4

Markus.Koechl
Autodesk
Autodesk

Your extension applies to a custom object, right? If so, I don't see that you registered the custom object's internal name for the command site location. 

For quick reference I am sharing the piece of code, that does the job adding context menus to the custom object's workspace: 

public class mClsChangeMgmtExt : IExplorerExtension
    {
        public const string mECRSystemName = "395e6304-6a49-4363-842c-3b791bffda09";
        public IEnumerable<CommandSite> CommandSites()
        {
            List<CommandSite> sites = new List<CommandSite>();
            // Describe user history command item
            //

            CommandItem mGoToEco = new CommandItem("Command.TestCommand2", "Go To ECO");
            SelectionTypeId mECRSelectionType = new SelectionTypeId(mECRSystemName);
            mGoToEco.NavigationTypes = new SelectionTypeId[] { mECRSelectionType };
            mGoToEco.MultiSelectEnabled = false;
            mGoToEco.Execute += mGoToEco_Execute;
            CommandSite mEcrContextMenu = new CommandSite("Menu.ECRContextMenu", "Go To ECO");
            CommandSiteLocation mECRCommandSiteLoc = new CommandSiteLocation(mECRSelectionType.EntityClassSubType, CommandSiteLocationType.ContextMenu);
            mEcrContextMenu.Location = mECRCommandSiteLoc;
            mEcrContextMenu.DeployAsPulldownMenu = false;
            mEcrContextMenu.AddCommand(mGoToEco);
            sites.Add(mEcrContextMenu);

            CommandItem mGoToECR = new CommandItem("Command.EcoContextMenu", "Go To ECR");
            mGoToECR.NavigationTypes = new SelectionTypeId[] { SelectionTypeId.ChangeOrder };
            mGoToECR.MultiSelectEnabled = false;
            mGoToECR.Execute += mGoToECR_Execute;
            CommandSite mEcoContextMenu = new CommandSite("Menu.ECOContextMenu", "Go To ECR");
            mEcoContextMenu.Location = CommandSiteLocation.ChangeOrderContextMenu;
            mEcoContextMenu.DeployAsPulldownMenu = false;
            mEcoContextMenu.AddCommand(mGoToECR);
            sites.Add(mEcoContextMenu);

            return sites;
        }

 Hope this helps. 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 3 of 4

Anonymous
Not applicable

I'm more so trying to add a toolbar to house commands like this:vaultCustomQuestion.PNGI'm not using the vault "Custom Objects". We want to be able to push the toolbar out to users without them having to manually add one themselves.

 

 

0 Likes
Message 4 of 4

Anonymous
Not applicable

Hi Aschwoerer,

 

Did you find a solution for this post? I'm trying to create a new main menu without a context for my custom tools.

 

C# Code:

 

CommandSiteLocation testToolbarCmdSiteLoc = new CommandSiteLocation(null, CommandSiteLocationType.Menu);
CommandSite toolbarCmdSite = new CommandSite("TestCommand.Menu", "Add New TestCommand Menu");
toolbarCmdSite.DeployAsPulldownMenu = false;
toolbarCmdSite.Location = testToolbarCmdSiteLoc;
toolbarCmdSite.AddCommand(bollegraafAboutCommandItem);

 

 

0 Likes