Active Member
Posts: 8
Registered: ‎08-07-2009
Message 1 of 4 (406 Views)

How to create a ribbon upon loading the dll

406 Views, 3 Replies
05-07-2012 12:55 PM


Sorry for asking this newbie question. I could not figure it out how to do this.

I found a sample project named RibbonSample in which by running a command, a new tab will be added to the ribbon.

I am trying to have that tab added upon loading the dll. So I added that command in the constructor of the dll, by "

SendStringToExecute" command. But the new tab did not show up. Then I added the method which creates the tab in the constructor, and I found the same thing. In both cases, when I type the command for creating the ribbon tab, a second tab, along with the first tab I added in the constructor, show up.

So I guess two possible options I have:

  •  first, find a way to make the new ribbon tab to be shown at first place, when the dll is loaded.
  •  Second, to find a way to postpone running a command added in the constructor of the dll, until the dll is loaded, so it can run like when I type it.

Your insights would be much appreciated.




*Expert Elite*
Posts: 753
Registered: ‎02-13-2008
Message 2 of 4 (397 Views)

Re: How to create a ribbon upon loading the dll

05-07-2012 04:24 PM in reply to: massoudshakeri

No garuantees, but I have had success using ads_queueexpr in the initialize routine, and DocumentActivated event, to do things that I could not otherwise do, because of the state of the document or application.


It essentially puts a command on the command stack, which will then be executed when AutoCAD has become ready to execute commands.  (I'm not sure why it is any different from SendStringToExecute, but I believe that it is)


It is an ARX command, which needs to be P/Invoked from .NET


<System.Runtime.InteropServices.DllImport("acad.exe", CharSet:=System.Runtime.InteropServices.CharSet.Unicode, CallingConvention:=System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint:="ads_queueexpr")> _
Public Shared Function ads_queueexpr(expression As String) As Integer
End Function



[DllImport("acad.exe", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
extern static private int ads_queueexpr(string strExpr);



Dave O.                                                                  Sig-Logos32.png
Active Member
Posts: 8
Registered: ‎08-07-2009
Message 3 of 4 (384 Views)

Re: How to create a ribbon upon loading the dll

05-07-2012 06:54 PM in reply to: chiefbraincloud

Thanks for your response.

As I found in the ObjectArx help, it says:

Do not use ads_queueexpr() in any context other then the kLoadDwgMsg case of acrxEntryPoint()

Moreover, I found in another discussion that to use it in Acad 2013, we need to use "accore.dll" instead. But the sample code was in VB.NET, so I translated that to C# as following :


 [DllImport("accore.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ads_queueexpr")]


public static extern int ads_queueexpr(string strExpr);


then added this line in the constructor:

ads_queueexpr("MyRIBBON ");

But it seems it does not work.

Am I missing something?


Posts: 1,452
Registered: ‎04-09-2008
Message 4 of 4 (377 Views)

Re: How to create a ribbon upon loading the dll

05-07-2012 09:50 PM in reply to: massoudshakeri

What about

ads_queueexpr("(command \"MyRIBBON\")");


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.