Lisp to import custom ribbon and tool bar if they dent exist.

Lisp to import custom ribbon and tool bar if they dent exist.

anieves228
Enthusiast Enthusiast
904 Views
7 Replies
Message 1 of 8

Lisp to import custom ribbon and tool bar if they dent exist.

anieves228
Enthusiast
Enthusiast

Hi All,

 

Is there a way to use lisp to import a custom ribbon on a machine if it doesn't exist?

 

I see mixed thoughts. one says use .NET framework and I see one for menues but not what I'm looking for and I have ZERO experience with .NET framework. 

 

Thank in advance!

0 Likes
Replies (7)
Message 2 of 8

pendean
Community Legend
Community Legend

What is your goal: for example, are you trying to add a custom ribbon to a few hundred AutoCAD seats?

Or is this a "ribbon" that is constantly changing over and over again?

 

Or something else?

0 Likes
Message 3 of 8

Sea-Haven
Mentor
Mentor

Have a look at this it will unload a menu if it exists or just load a new one. 

 

(setq Menu_Path "C:\\yourpath\\") ; Path to Menu file
(setq Menu_Name "yourmenuname") ; pop menu to load
(setq Group_Name "YourMENU") ; groupname assigned in .mnu or .mns file

(if (menugroup menu_Name)
(command "_MENUUNLOAD" menu_Name)
)
(setq cnt (vla-get-count(vla-get-menuGroups (vlax-get-acad-object))))
(if  (> (vl-string-search  "BricsCAD" (getvar 'acadver)) 0)
(progn
(command "MENULOAD" (strcat Menu_Path Menu_Name ".CUI"))
(menucmd (strcat "P" (rtos (+ cnt 1) 2 0) "=+" menu_Name ".POP1"))
)
(progn
(command "MENULOAD" (strcat Menu_Path Menu_Name ".cuix"))
(menucmd (strcat "P" (rtos (+ cnt 1) 2 0) "=+" menu_Name ".POP1"))
)
)

 

 

0 Likes
Message 4 of 8

anieves228
Enthusiast
Enthusiast

Yes. It will be sent to +50 machines and it will be updated as needed, but it will be frequently updated when first implemented.

0 Likes
Message 5 of 8

pendean
Community Legend
Community Legend

@anieves228 wrote:

Yes. It will be sent to +50 machines and it will be updated as needed, but it will be frequently updated when first implemented.


Good lisp above for your use.

 

BUT... have you all considered implementing an ENTERPRISE menu instead? it's built into the program an works well for situations like yours

https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-B3F0CB28-99D6-48B5-99C7-3E58249BB18C#:~:text=...

0 Likes
Message 6 of 8

anieves228
Enthusiast
Enthusiast

Question. 

 

path to file menu file would be the .cuix file location correct?

 

Then the Ribbon name would be the Menu_name?

 

Now I don't have a .mnu or .mns file. I have a .mnr file that is generated. Which I think is causing me an issue. 

 

I comment out the first (progn) since mine is a .cuix not an .cui. 

 

So I'm not sure where to go from here. 

 

(setq Menu_Path "x:\\zCAD\\Tools\\cui\\") ; Path to Menu file
(setq Menu_Name "Company Custom") ; pop menu to load
(setq Group_Name "Company Custom") ; groupname assigned in .mnu or .mns file

(if 
  (menugroup menu_Name)
  (command "_MENUUNLOAD" menu_Name)
)

(setq cnt 
  (vla-get-count
    (vla-get-menuGroups
      (vlax-get-acad-object)
    )
  )
)

(if  
  (> 
    (vl-string-search  "BricsCAD"
      (getvar 'acadver)
    ) 0
  )
  
  ; (progn
  ;   (command "MENULOAD" (strcat Menu_Path Menu_Name ".CUI"))
  ;   (menucmd (strcat "P" (rtos (+ cnt 1) 2 0) "=+" menu_Name ".POP1"))
  ; )
  
  (progn
    (command "MENULOAD" (strcat Menu_Path Menu_Name ".cuix"))
    (menucmd (strcat "P" (rtos (+ cnt 1) 2 0) "=+" menu_Name ".POP1"))
  )
)

 

0 Likes
Message 7 of 8

anieves228
Enthusiast
Enthusiast

Also. it still stops and asks for the customization file

error.png

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

(setq Menu_Name "name of your mnu file")

 

Need to look at 1st few lines of a mnu file,  **MENUGROUP=this is name of menu group

(setq Group_Name "this is name of menu group")

0 Likes