Adding my own toolbar

Adding my own toolbar

A.WagnerKWWFA
Enthusiast Enthusiast
1,198 Views
5 Replies
Message 1 of 6

Adding my own toolbar

A.WagnerKWWFA
Enthusiast
Enthusiast

Hello,

i'm looking for a sample code for creating my own toolbar.

My code i using for adding one command to the "AdvancedToolbar".

 

CommandItem CopyLinkCmdItem = new CommandItem("CommandCL", "Copy Link")
{
  NavigationTypes = new SelectionTypeId[] { SelectionTypeId.File },
  MultiSelectEnabled = false
};
CommandSite toolbarCmdSite = new CommandSite("SampleCommand.Toolbar", "Hello World Menu")
{
  Location = CommandSiteLocation.AdvancedToolbar,
  DeployAsPulldownMenu = false
};
toolbarCmdSite.AddCommand(CopyLinkCmdItem);


i want to place this command, and some others, on my own toolbar.

 

 

0 Likes
1,199 Views
5 Replies
Replies (5)
Message 2 of 6

mfoster9TD82
Advocate
Advocate

If you're having trouble getting everything set up try following these steps:

https://jasinskidev.com/creating-your-first-extension-for-autodesk-vault-2022/

Once you get that set up insert your command site code into the CommandSites function in the IExplorerExtension interface.

The HelloWorld template in the vault SDK folder is a good starting place for toolbar commands.

Best of luck!

Edit: Don't forget to get a new GUID for each extension if you have multiple.

0 Likes
Message 3 of 6

A.WagnerKWWFA
Enthusiast
Enthusiast

After reading the following thread

https://forums.autodesk.com/t5/vault-customization/programmatically-create-custom-toolbar-to-hold-cu... 

i have tried to adapt that to a custom toolbar with a button.

 

It didn't work. I have changed "CommandSiteLocationType.ContextMenu" to "CommandSiteLocationType.Toolbar".

 

Even the first two lines "new SelectionTypeId" and "new CommandSiteLocation" destroys all other custom Buttons in the "CommandSiteLocation.AdvancedToolbar".

 

 

 

 

public const string mECRSystemName = "395e6304-6a49-4363-842c-3b791bffda09";

 public IEnumerable<CommandSite> CommandSites()
        {

            SelectionTypeId mECRSelectionType = new SelectionTypeId(mECRSystemName);
            CommandSiteLocation mECRCommandSiteLoc = new CommandSiteLocation(mECRSelectionType.EntityClassSubType, CommandSiteLocationType.Toolbar  );
			
			
			 CommandItem TestButtItem = new CommandItem("TestButt", "Testbutton")
            {
                NavigationTypes = new SelectionTypeId[] { mECRSelectionType },
                MultiSelectEnabled = false
            };
			
			
			TestButtItem.Execute += TestButtItemCommandHandler;
			
			
			CommandSite testbuttCmdSite = new CommandSite("SKGCommand.Testbutt", "Testmenu")
            {
                Location = mECRCommandSiteLoc,
                DeployAsPulldownMenu = false
            };
            testbuttCmdSite.AddCommand(TestButtItem);
			
			sites.Add(testbuttCmdSite);
			
		}	

 

0 Likes
Message 4 of 6

mattias.viklund01
Participant
Participant
public const string mECRSystemName = "395e6304-6a49-4363-842c-3b791bffda09";
SelectionTypeId mECRSelectionType = new SelectionTypeId(mECRSystemName);

You don't need a Selection Type on your command.

Unless you want it to handle something specific like the currently selected file, folder or custom object.

 

CommandItem TestButtItem = new CommandItem("TestButt", "Testbutton")
{
    MultiSelectEnabled = false
};
	
TestButtItem.Execute += TestButtItemCommandHandler;			
			
CommandSite testbuttCmdSite = new CommandSite("SKGCommand.Testbutt", "Testmenu")
{
    Location = CommandSiteLocation.AdvancedToolbar,
    DeployAsPulldownMenu = false
};

testbuttCmdSite.AddCommand(TestButtItem);
sites.Add(testbuttCmdSite);

 

This should be plenty to get a command working.

0 Likes
Message 5 of 6

A.WagnerKWWFA
Enthusiast
Enthusiast
 Location = CommandSiteLocation.AdvancedToolbar,

This places the button in the AdvancedToolbar.

My problem is, that i want the button in a blank, new toolbar.

0 Likes
Message 6 of 6

mattias.viklund01
Participant
Participant

It isn't possible to create a new CommandSiteLocation for the toolbar.

It only works to create a new Context Menu for Custom Entitites.

 

Unfortunate quirk of the API.

0 Likes