I was looking for a keyboard shortcut to activate the home ribbon and have not found anything. Has anybody created something like this?
|
I was looking for a keyboard shortcut to activate the home ribbon and have not found anything. Has anybody created something like this?
Here's what I have so far:
Dim ribcontrol As RibbonControl = ComponentManager.Ribbon
ribcontrol.ActiveTab = "Home"
But it gives me a "String" error in Visual Studio.
Sorry I am very new to .Net
Got it, see below:
used code from here http://forums.autodesk.com/t5/NET/Ho...ET/m-p/3049040
Code:<CommandMethod("setHomeTab")> _ Public Sub setHomeTab() Dim activeDoc As Document = Application.DocumentManager.MdiActiveDocument Dim db As Database = activeDoc.Database Dim ed As Editor = activeDoc.Editor Dim i As Integer Dim ribcontrol As Autodesk.Windows.RibbonControl ribcontrol = Autodesk.Windows.ComponentManager.Ribbon Dim cnt As Integer cnt = ribcontrol.Tabs.Count For i = 0 To ribcontrol.Tabs.Count - 1 With ribcontrol.Tabs 'ed.WriteMessage("Name: " & .Item(i).Name & " ID:" & .Item(i).Id & Environment.NewLine) If .Item(i).Name = "Home - 2D" Then .Item(i).IsActive = True End If End With Next End Sub
Nice! Just a few queries :
Why the db variable? It's never used.
What about if the Home tab is named slightly differently? Say "Home - 3D"?
It was a cut and paste from the noted website, I should have reviewed it more in detail. I should have removed the db variable, it looks like it is not needed. If you would like the "Home - 3D" tab current just substitute "Home - 2D". I had to hard code "Home - 2D" because I assigned the program to a shortcut key (F1) with in the CUI.
+1
Or you could have it ask for input and set according to the string "entered". That way you can have a macro call your function with any of the ribbon tab names. No need to duplicate your function several times for other tabs.
Or even more "usable" would be to turn it into a Lisp-callable function, taking an argument as the Tab name.
What I'd do though is generate an inspection function returning a list of tab names. And/or even one which returns the currently active tab. But that's probably a bit too much ... just trying to think ahead.
If you want the Home Tab I think they all start with "Home" and if so this could work
Code:If .Item(i).Name.StartsWith("Home") Then .Item(i).IsActive = True End If