.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create a ribbon upon loading the dll

3 REPLIES 3
Reply
Message 1 of 4
massoudshakeri
860 Views, 3 Replies

How to create a ribbon upon loading the dll

Hi,

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.

Thanks

Massoud

 

3 REPLIES 3
Message 2 of 4

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

VB:

<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

 

C#

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

 

 

Dave O.                                                                  Sig-Logos32.png
Message 3 of 4

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?

Massoud

Message 4 of 4

What about

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

 ?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost