creating multiple tabs in Ribbon Toolbar

creating multiple tabs in Ribbon Toolbar

Anonymous
Not applicable
763 Views
4 Replies
Message 1 of 5

creating multiple tabs in Ribbon Toolbar

Anonymous
Not applicable

The Following lsp code works fine 

 

(defun-q S::STARTUP()
(command ".netload" "C:\\C3D\\QrPlugIn-C3D\\2018\\SNCL_C3DUtils.dll")
(command "QR")
)

;(c:test)

 

When I Open or create a new document in Civil 3D, It is creating multiple tabs like "1 click Viz". Attached here is the screenshot. How to stop the next one? It should create only one tab. Kindly suggest

0 Likes
764 Views
4 Replies
Replies (4)
Message 2 of 5

Virupaksha_aithal
Autodesk Support
Autodesk Support

Hi,

 

Can you share information on how the "1 click Viz" ribbon tab is getting created? can you please share the procedure so that we can reproduce the issue at our end? also, test the sample present in http://adndevblog.typepad.com/autocad/2012/06/ribbonsplitbutton-with-icons-images.html 

 

 



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

norman.yuan
Mentor
Mentor

The issue is with the LISP code you use.

 

You use the old fashion "S::STARTUP" to load the DLL and execute command defined in the DLL. Depending on how/where the S:STARTUP is called in your AutoCAD setup, it could be called multiple times (only you know it). To me, it looks like it gets called on after each drawing is opened in AutoCAD, thus the DLL is loaded each time (but after first load, the next "NETLOAD" call would do nothing, because the DLL has already been loaded).

 

The problem is the call (command "QR"), which I believe does the custom ribbon tab creation. As you can see, since it called multiple times (probably on each drawing opened), thus a tab with the same name/content would be created repeatedly.

 

The things you need to do (all, or combination of them) are:

1. Make sure the DLL only load once (call "NETLOAD" once), which may not be harmful even it called more then once, though;

2. Implement the IExtensionApplication with your DLL, so that the Tab creation is done in Initialize(), thus, the tab only get created once;

3. In your actual code (wrapped in command "QR"), you would examine existing ribbon control for all existing tabs (by its name and/or ID, and only create your custom tab if it does not exist.

 

I'd think 3 would be better choice, because during the same AutoCAD session, you may need to make sure the tab always there, even user changes WorkSpace (thus, you may want to handle WorkSpace_Changed event to re-create the tab, if necessary).

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 4 of 5

Anonymous
Not applicable

The following code works. Thank you Norman

RibbonTab rt = rc.FindTab("");

if (rt != null)

 

{

return;

 

}

 

0 Likes
Message 5 of 5

Anonymous
Not applicable

Thank you Virupaksha

 

The following code worked.

RibbonTab rt = rc.FindTab("");

if (rt != null)

 

{

return;

 

}

 

0 Likes