[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1702
  • Last Modified:

Trying to make a ribbon tab active in AutoCAD 2012 using VB.NET

I am trying to write a simple program for AutoCAD 2012 using VB.NET to make a specific tab in the ribbon active but since I am very new to vb.net am having trouble with it, below is the main part of the program.  Visual Studio is giving me an error for "Home" stating:

Value of type 'String' cannot be converted to 'Autodesk.Windows.RibbonTab'

"Home" is the name of the ribbon tab which I would like to make active.
Private Sub SetRibbonTab()
   Dim ribcontrol As RibbonControl = ComponentManager.Ribbon
   ribcontrol.ActiveTab = "Home"
End Sub

Open in new window

0
GreyHippo
Asked:
GreyHippo
  • 3
  • 3
1 Solution
 
silverkornCommented:
see the discussion here:
http://forums.autodesk.com/t5/NET/How-to-Load-CUI-File-Ribbon-Tabs-And-Make-Visible-via-NET/m-p/3049040

a user had uploaded a sample code file that shows the switching of ribbon tabs
0
 
GreyHippoAuthor Commented:
That's what I started with but I can't figure out how to add the name of the tab to make active.
0
 
silverkornCommented:
as per: http://forums.autodesk.com/t5/NET/Options-Dialog-Tab-Pre-Selection/m-p/2400125/highlight/true#M12755

it appears that the ActiveTab is looking for an integer value, so try the value of 1

another example could be found here:
http://forums.autodesk.com/t5/NET/Total-n00b-trying-to-use-net-to-create-ribbon-bar-addins/m-p/2880120/highlight/true#M22189

in which they use the following code to create a new tab and set it active:
 
Private Sub CreateRibbon()
        'declare a ribboncontrol object
        Dim ribCntrl As RibbonControl = ComponentManager.Ribbon
        'create a ribbontab
        Dim ribTab As New RibbonTab()
        'set a few properties
        ribTab.Title = "AU2009"
        ribTab.Id = "AU2009"
        'add the tab to the ribbon
        ribCntrl.Tabs.Add(ribTab)
        'set as active tab
        ribTab.IsActive = True

    End Sub

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
GreyHippoAuthor Commented:
I tried adding a 1 but received a similar error: "Value of type 'Integer' cannot be converted to 'Autodesk.Windows.RibbonTab' "

I found that other example but they are trying to create a new tab and making it active.

0
 
silverkornCommented:
after looking more closely at the code from the previous link: http://forums.autodesk.com/t5/NET/How-to-Load-CUI-File-Ribbon-Tabs-And-Make-Visible-via-NET/m-p/3049040

at the very end of the Class1.vb file in the VBExample file they have a for loop to find the tab named Autodesk and then set it active, so from there you could try this line of code to replace your line 3:

ribcontrol.Tabs.Item(0).IsActive = True
0
 
GreyHippoAuthor Commented:
Thanks that worked
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now