AutoCAD Map 3D General Discussion

Reply
Active Contributor
chase.hochstrasser
Posts: 42
Registered: ‎07-17-2013
Message 1 of 4 (1,645 Views)
Accepted Solution

VB.NET Create Ribbon

1645 Views, 3 Replies
08-17-2013 07:35 AM

I have recently designed a Ribbon and everything works great while running the DLL on my own machine but it does not work when i give the dll to my co-workers. What i'm i missing from my code? I think i need an example of how to create a ribbon with in vb.net (Visual Studio 2010). Do i need to attach my ribbon to the WSCURRENT (worksation current)? I have a addler for each button on my ribbon, and this all works.... but i did find out that even on my own machine if i close the ribbon after opening it using NETLOAD then it will be gone forever and it will not load again using the NETLOAD. 

 

can someone show me an example of x64 VB.NET AutoCAD map 3D 2011 that has a ribbon customized buttons?

*Expert Elite*
Alfred.NESWADBA
Posts: 8,887
Registered: ‎06-29-2007
Message 2 of 4 (1,641 Views)

Re: VB.NET Create Ribbon

08-17-2013 07:56 AM in reply to: chase.hochstrasser

Hi,

 

>>>that<<< might help.

 

For the next questions about .NET based AutoCAD development check that: >>>click<<<, as your question is not specific to Map3D development. If you have questions about Map3D development there is also a separate space in this forum >>>here<<<.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Contributor
chase.hochstrasser
Posts: 42
Registered: ‎07-17-2013
Message 3 of 4 (1,600 Views)

Re: VB.NET Create Ribbon

08-19-2013 10:40 AM in reply to: Alfred.NESWADBA

This Still does not work as expected. I'm able to see my ribbon with tabs and buttons but if i change the workspace it will disappear and i can't add it back unless i quit out of autocad and restart autocad map 3d. I have added my code as a text document. Any Ideas?

Active Contributor
chase.hochstrasser
Posts: 42
Registered: ‎07-17-2013
Message 4 of 4 (1,568 Views)

Re: VB.NET Create Ribbon

08-20-2013 09:48 AM in reply to: chase.hochstrasser

<CommandMethod("CreateRibbon")> _
Public Sub CreateRibbon()

'' Declare a ribbonControl Object
Dim ribCntrl As RibbonControl = ComponentManager.Ribbon
Dim ribTab As RibbonTab = New RibbonTab

'' Set a few properties
ribTab.Title = "Field Engineering ToolBar"
ribTab.Id = "Field Engineering ToolBar"
ribTab.Name = "Field Engineering ToolBar"
ribTab.Description = "Field Engineering ToolBar"
ribTab.IsContextualTab = False

'' Add the tab to the ribbon
ribCntrl.Tabs.Add(ribTab)

'' Add Content to Ribbon
'' Create the panel source
Dim ribSourcePanel As RibbonPanelSource = New RibbonPanelSource()
ribSourcePanel.Title = "Feild Engineering Tools"

'' Now the panel
Dim ribPanel As RibbonPanel = New RibbonPanel()
ribPanel.Source = ribSourcePanel
ribTab.Panels.Add(ribPanel)

'' Create a map button
Dim mapBtn As RibbonButton = New RibbonButton()
mapBtn.Text = "New Map"
mapBtn.CommandParameter = "MAKEMAP "
mapBtn.ShowText = True
mapBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.NewMap)
mapBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.NewMap)
mapBtn.ShowImage = True
mapBtn.CommandHandler = New RibbonCommandHandler()
mapBtn.Size = RibbonItemSize.Large
mapBtn.Orientation = Windows.Controls.Orientation.Vertical

'' Create a To Excel button
Dim ExcelBtn As RibbonButton = New RibbonButton()
ExcelBtn.Text = "Export To Excel"
ExcelBtn.CommandParameter = "ToExcel "
ExcelBtn.ShowText = True
ExcelBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.Excel_icon)
ExcelBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.Excel_icon)
ExcelBtn.ShowImage = True
ExcelBtn.CommandHandler = New RibbonCommandHandler()
ExcelBtn.Size = RibbonItemSize.Large
ExcelBtn.Orientation = Windows.Controls.Orientation.Vertical

'' Create a fuse Right button
Dim FRBtn As RibbonButton = New RibbonButton()
FRBtn.Text = "Fuse Right"
FRBtn.CommandParameter = "FuseRight "
FRBtn.ShowText = True
FRBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.fuseR)
FRBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.fuseR)
FRBtn.ShowImage = True
FRBtn.CommandHandler = New RibbonCommandHandler()
FRBtn.IsEnabled = False

'' Create a fuse left button
Dim FLBtn As RibbonButton = New RibbonButton()
FLBtn.Text = "Fuse Left"
FLBtn.CommandParameter = "FuseLeft "
FLBtn.ShowText = True
FLBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.fuseL)
FLBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.fuseL)
FLBtn.ShowImage = True
FLBtn.CommandHandler = New RibbonCommandHandler()
FLBtn.IsEnabled = False

'' Create a Recloser button
Dim ReclBtn As RibbonButton = New RibbonButton()
ReclBtn.Text = "Add Recloser"
ReclBtn.CommandParameter = "Recloser "
ReclBtn.ShowText = True
ReclBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.recloser)
ReclBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.recloser)
ReclBtn.ShowImage = True
ReclBtn.CommandHandler = New RibbonCommandHandler()
ReclBtn.IsEnabled = False

'' Create a Sectionalizer button
Dim SectiBtn As RibbonButton = New RibbonButton()
SectiBtn.Text = "Add Sectionalizer"
SectiBtn.CommandParameter = "Sectionalizer "
SectiBtn.ShowText = True
SectiBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.sectionalizer)
SectiBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.sectionalizer)
SectiBtn.ShowImage = True
SectiBtn.CommandHandler = New RibbonCommandHandler()
SectiBtn.IsEnabled = False

'' Create a Facility Point Toggle button
Dim FPBtn As RibbonButton = New RibbonButton()
FPBtn.Text = "Facility Point Toggle"
FPBtn.CommandParameter = "FPToggle "
FPBtn.ShowText = True
FPBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.fptoggle)
FPBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.fptoggle)
FPBtn.ShowImage = True
FPBtn.CommandHandler = New RibbonCommandHandler()
FPBtn.IsEnabled = False

'' Create a Legend button
Dim LegBtn As RibbonButton = New RibbonButton()
LegBtn.Text = "Legend"
LegBtn.CommandParameter = "Legend "
LegBtn.ShowText = True
LegBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.Legend)
LegBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.Legend)
LegBtn.ShowImage = True
LegBtn.CommandHandler = New RibbonCommandHandler()
LegBtn.IsEnabled = False

'' Create a Title Block button
Dim TitleBtn As RibbonButton = New RibbonButton()
TitleBtn.Text = "Title Block"
TitleBtn.CommandParameter = "TitleBlock "
TitleBtn.ShowText = True
TitleBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.titleblock)
TitleBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.titleblock)
TitleBtn.ShowImage = True
TitleBtn.CommandHandler = New RibbonCommandHandler()
TitleBtn.IsEnabled = False

'' Create a Short Circuit button
Dim ShortBtn As RibbonButton = New RibbonButton()
ShortBtn.Text = "Short"
ShortBtn.CommandParameter = "Short "
ShortBtn.ShowText = True
ShortBtn.Image = RibbonCommandHandler.LoadImage(My.Resources._short)
ShortBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources._short)
ShortBtn.ShowImage = True
ShortBtn.CommandHandler = New RibbonCommandHandler()
ShortBtn.IsEnabled = False

'' Create a Insert Text button
Dim TextBtn As RibbonButton = New RibbonButton()
TextBtn.Text = "Insert Text"
TextBtn.CommandParameter = "Text "
TextBtn.ShowText = False
TextBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.Text)
TextBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.Text)
TextBtn.ShowImage = True
TextBtn.CommandHandler = New RibbonCommandHandler()
TextBtn.IsEnabled = False

'' Create a Print button
Dim PrintBtn As RibbonButton = New RibbonButton()
PrintBtn.Text = "Print"
PrintBtn.CommandParameter = "Print "
PrintBtn.ShowText = False
PrintBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.Printer)
PrintBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.Printer)
PrintBtn.ShowImage = True
PrintBtn.CommandHandler = New RibbonCommandHandler()
PrintBtn.IsEnabled = False

'' Create a Capacitor button
Dim CapBtn As RibbonButton = New RibbonButton()
CapBtn.Text = "Insert Capacitor"
CapBtn.CommandParameter = "Capacitor "
CapBtn.ShowText = False
CapBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.CapList)
CapBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.CapList)
CapBtn.ShowImage = True
CapBtn.CommandHandler = New RibbonCommandHandler()
CapBtn.IsEnabled = False

'' Create a Scale button
Dim ScaleBtn As RibbonButton = New RibbonButton()
ScaleBtn.Text = "Transform - Scale"
ScaleBtn.CommandParameter = "Scale "
ScaleBtn.ShowText = False
ScaleBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.scale)
ScaleBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.scale)
ScaleBtn.ShowImage = True
ScaleBtn.CommandHandler = New RibbonCommandHandler()
ScaleBtn.IsEnabled = False

'' Create a Fault Indicator button
Dim FaultBtn As RibbonButton = New RibbonButton()
FaultBtn.Text = "Fault Indicator"
FaultBtn.CommandParameter = "FaultIndicator "
FaultBtn.ShowText = True
FaultBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.faultInd)
FaultBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.faultInd)
FaultBtn.ShowImage = True
FaultBtn.CommandHandler = New RibbonCommandHandler()
FaultBtn.IsEnabled = False

'' Create a Import Profile button
Dim ProfileBtn As RibbonButton = New RibbonButton()
ProfileBtn.Text = "Import Profile"
ProfileBtn.CommandParameter = "UserProfile "
ProfileBtn.ShowText = True
ProfileBtn.Image = RibbonCommandHandler.LoadImage(My.Resources.Users)
ProfileBtn.LargeImage = RibbonCommandHandler.LoadImage(My.Resources.Users)
ProfileBtn.ShowImage = True
ProfileBtn.CommandHandler = New RibbonCommandHandler()
ProfileBtn.Size = RibbonItemSize.Large
ProfileBtn.Orientation = Windows.Controls.Orientation.Vertical
ProfileBtn.IsEnabled = False

'' RibbonRowPanel
Dim ribRowPan As New RibbonRowPanel
ribRowPan.Items.Add(FRBtn)
ribRowPan.Items.Add(New RibbonRowBreak)
ribRowPan.Items.Add(FLBtn)
ribRowPan.IsTopJustified = True

'' RibbonRowPanel
Dim ribRowPan2 As New RibbonRowPanel
ribRowPan2.Items.Add(ReclBtn)
ribRowPan2.Items.Add(New RibbonRowBreak)
ribRowPan2.Items.Add(SectiBtn)
ribRowPan2.Items.Add(New RibbonRowBreak)
ribRowPan2.Items.Add(FaultBtn)
ribRowPan2.Items.Add(ShortBtn)
ribRowPan2.IsTopJustified = True

'' RibbonRowPanel
Dim ribRowPan3 As New RibbonRowPanel
ribRowPan3.Items.Add(LegBtn)
ribRowPan3.Items.Add(New RibbonRowBreak)
ribRowPan3.Items.Add(TitleBtn)
ribRowPan3.Items.Add(New RibbonRowBreak)
ribRowPan3.Items.Add(ScaleBtn)
ribRowPan3.Items.Add(CapBtn)
ribRowPan3.IsTopJustified = True

'' RibbonRowPanel
Dim ribRowPan4 As New RibbonRowPanel
ribRowPan4.Items.Add(TextBtn)
ribRowPan4.Items.Add(New RibbonRowBreak)
ribRowPan4.Items.Add(PrintBtn)
ribRowPan4.IsTopJustified = True

'' Add the buttons
ribSourcePanel.Items.Add(ribRowPan)
ribSourcePanel.Items.Add(New RibbonSeparator)
ribSourcePanel.Items.Add(ribRowPan2)
ribSourcePanel.Items.Add(New RibbonSeparator)
ribSourcePanel.Items.Add(ribRowPan3)
ribSourcePanel.Items.Add(New RibbonSeparator)
ribSourcePanel.Items.Add(ExcelBtn)
ribSourcePanel.Items.Add(New RibbonSeparator)
ribSourcePanel.Items.Add(mapBtn)
ribSourcePanel.Items.Add(New RibbonSeparator)
ribSourcePanel.Items.Add(ribRowPan4)
ribSourcePanel.Items.Add(ProfileBtn)

'' Set as active tab
ribTab.IsActive = True

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community