By Wayne Brill
If you need to remove an existing tab from workspace tabs using the name of the tab, you can iterate the RibbonTabSource elements and get the ElementID from the RibbonTabSource. (The RibbonTabSource class has a name property) The ElementID will be the TabId of the WSRibbonTabSourceReference. Below is the pertinent code from the AutoCAD 2013 C# project. (_TestFindWithRibbonTab) The command "DELTAB" finds the Home 2D Tab and removes it from a workspace.
Download _Test_FindWithRibbonTab
Note: Keep in mind that it could be possible that there is more than one RibbonTabSource with the same name. (ElementID and TabId are unique in a menu group however)
[CommandMethod("DELTAB")]
public void delTab()
{
WSRibbonRoot wrkSpaceRibbonRoot = null;
WorkspaceRibbonTabCollection
wsRibbonTabCollection = null;
Editor ed =
Autodesk.AutoCAD.ApplicationServices.
Application.DocumentManager.
MdiActiveDocument.Editor;
try
{
WorkspaceCollection WsCollect =
cs.Workspaces;
if ((WsCollect.Count

Leave a Reply