.NET

Reply
Distinguished Contributor
Irvin
Posts: 112
Registered: ‎04-22-2009
Message 11 of 25 (1,875 Views)

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

Valued Contributor
deathman20
Posts: 55
Registered: ‎11-08-2010
Message 12 of 25 (1,873 Views)

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

 

 

New Member
tamer.elbakkali
Posts: 1
Registered: ‎09-20-2011
Message 13 of 25 (1,560 Views)

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

Valued Contributor
cean_au
Posts: 100
Registered: ‎07-11-2011
Message 14 of 25 (1,514 Views)

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.

Active Contributor
kapil_CCTech
Posts: 39
Registered: ‎06-07-2012
Message 15 of 25 (1,128 Views)

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.

Distinguished Contributor
eljobe
Posts: 704
Registered: ‎01-24-2003
Message 16 of 25 (1,119 Views)

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.

Active Member
massoudshakeri
Posts: 8
Registered: ‎08-07-2009
Message 17 of 25 (1,093 Views)

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

New Member
Alexandru_Meca
Posts: 1
Registered: ‎12-12-2012
Message 18 of 25 (899 Views)

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

Active Contributor
NLeininger
Posts: 27
Registered: ‎03-21-2013
Message 19 of 25 (646 Views)

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?

Valued Contributor
raghulan
Posts: 92
Registered: ‎01-11-2012
Message 20 of 25 (593 Views)

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

07-09-2013 11:47 PM in reply to: deathman20

Hello guys, 

 

 how to assign a button color, instead of image.

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.