• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Distinguished Contributor
    Posts: 112
    Registered: ‎04-22-2009

    Re: Create custom ribbon tab and buttons for Autocad mechanical 2011?

    01-19-2011 02:34 AM in reply to: SMachado

    Hi there,

     

    Are you using c# or VB.NET???

     

    If you are using vb.net replace the RibbonCommandhandler class with this code:

    I looked a the converted VB.net code in this thread but there are some strange things in it.

     

    Public Class RibbonCommandHandler
    	Implements System.Windows.Input.ICommand
    	Public Function CanExecute(parameter As Object) As Boolean
    		Return True
    	End Function
    
    	Public Event CanExecuteChanged As EventHandler
    
    	Public Sub Execute(parameter As Object)
    		Dim doc As Document = acadApp.DocumentManager.MdiActiveDocument
    
    		If TypeOf parameter Is RibbonButton Then
    			Dim button As RibbonButton = TryCast(parameter, RibbonButton)
    			doc.Editor.WriteMessage(vbLf & "RibbonButton Executed: " + button.Text + vbLf)
    		End If
    	End Sub
    End Class

     

    It's correct you get a warning an CanExecuteChanged. It's nessecery when you use 
    System.Windows.Input.ICommand but should compile.

     

    Kind regards,

     

    Irvin

    Please use plain text.
    Valued Contributor
    deathman20
    Posts: 54
    Registered: ‎11-08-2010

    Re: Create custom ribbon tab and buttons for Autocad mechanical 2011?

    01-19-2011 05:54 AM in reply to: Irvin

    Hi there,

     

    Sorry forgot to say I was using your script as is, just changed the references to pull up the proper DLL's.  So its C#.

     

    Though I can't get anything to load into Autocad so figuring that error, or warning I should say I was getting was because of that.

     

    Thanks,

    Dman

     

     

    Please use plain text.
    New Member
    tamer.elbakkali
    Posts: 1
    Registered: ‎09-20-2011

    Re: Create custom ribbon tab and buttons for Autocad mechanical 2011?

    09-20-2011 09:25 AM in reply to: Irvin

    Hi Irvin,

     

    i'm trying actually to create a custom ribbon for autocad mechanical 2010. I saw you exemple and I run it in visual studio 2010 with a debug configuration, as a result, there is no error and it seems everything is ok.. but after that autocad's opened I can not see the ribbon !  did i miss something ? btw i tryed a .net version and it also returns the same result !

     

    Tamer,

    Regards

    Please use plain text.
    Valued Contributor
    cean_au
    Posts: 100
    Registered: ‎07-11-2011

    Re: Create custom ribbon tab and buttons for Autocad mechanical 2011?

    09-29-2011 08:49 PM in reply to: Irvin

    Public Class RibbonCommandHandler Implements System.Windows.Input.ICommand Public Function CanExecute(ByVal parameter As Object) As Boolean Implements System.Windows.Input.ICommand.CanExecute Return True End Function Public Event CanExecuteChanged(ByVal sender As Object, ByVal e As System.EventArgs) Implements System.Windows.Input.ICommand.CanExecuteChanged Public Sub Execute(ByVal parameter As Object) Implements System.Windows.Input.ICommand.Execute Dim doc As Document = Application.DocumentManager.MdiActiveDocument If TypeOf parameter Is RibbonButton Then Dim button As RibbonButton = TryCast(parameter, RibbonButton) doc.Editor.WriteMessage(vbLf & "RibbonButton Executed: " + button.Text & vbLf) End If End Sub End Class

     my RibbonCommandHandler. Don't know why I need to write like this: Public Function CanExecute(ByVal parameter As Object) As Boolean Implements System.Windows.Input.ICommand.CanExecute
    but it seems work. 

    I am using vb.next express 2008.

    Please use plain text.
    Active Contributor
    Posts: 39
    Registered: ‎06-07-2012

    Re: Create custom ribbon tab and buttons for Autocad mechanical 2011?

    06-26-2012 04:15 AM in reply to: Irvin

    I want to add ribbon using C++.... Tried a lot , but failed.

     

    Please help with code.

    Please use plain text.
    Distinguished Contributor
    Posts: 701
    Registered: ‎01-24-2003

    Re: Create custom ribbon tab and buttons for Autocad mechanical 2011?

    06-26-2012 09:17 AM in reply to: kapil_CCTech

    kapil_CCTech wrote:

    I want to add ribbon using C++.... Tried a lot , but failed.

     

    Please help with code.


    This is the .NET forum. You might want to try the ObjectArx (C++) forum.

    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎08-07-2009

    Re: Create custom ribbon tab and buttons for Autocad mechanical 2011?

    07-03-2012 03:10 PM in reply to: SMachado

    Hi,

    I tried to modify the code, so I added a few strings to one of the combo-boxes instead of RibbonButtons, with a code like this:

     

    String str1 = "String1";

    String str2 = "String2";

    pan3ribcombo.Items.Add(str1);

    pan3ribcombo.Items.Add(str2);

     

    in the EventHandler, I changed the code to:

               

    string but = pan3ribcombo.Current as string;

    acadApp.ShowAlertDialog(but);

    

    But the texts are not shown in the Combo-box and they are blank. When I change the current item, ShowAlertDialog shows the right text.

    How I can change it to have a Combo-box of texts?

    Thanks

    Please use plain text.
    New Member
    Posts: 1
    Registered: ‎12-12-2012

    Re: Create custom ribbon tab and buttons for Autocad mechanical 2011?

    12-12-2012 03:19 AM in reply to: SMachado

    Hy all,

     

    Can anyone to post a short example with a custom riboon tab created with Visual Studio for AutoCAD Map 3D 2013.

     

    The current exeple is good but when i tried to compile it for AutoCAD Map 3D i don't know what are the namespaces to validate the code.

     

    It will be helpfully if someone can specifie what are the namespaces for creating a riboon tab for AutoCAD Map 3D 2013.

     

    Thanks,

    Alexandru

    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎03-21-2013

    Re: Create custom ribbon tab and buttons for Autocad mechanical 2011?

    06-14-2013 01:16 PM in reply to: massoudshakeri

    I too would like an example of adding items to the RibbonCombo, as I would like them to behave like Window Forms comboboxes, if that is possible?

    Please use plain text.