what's the proper way to add custom menus using a script

what's the proper way to add custom menus using a script

fawzimasri7137
Advocate Advocate
1,641 Views
2 Replies
Message 1 of 3

what's the proper way to add custom menus using a script

fawzimasri7137
Advocate
Advocate

I have 2 cuix custom group that i want to auto-load when autocad is started, instead of using cuiload manually.

 

The reason for that is that sometime if autocad does not find these files due to network issues, it actually remove them from its list and i have to rerun cuiload one more time to get them back on its list.

 

It would be much easier if i can put them in some script like the acad.lsp and simply re-start autocad again.

 

This what i have tried in acad.lsp but could not see them loaded when i typed cuiload:

(vl-load-com)
(vla-put-supportpath
   (vla-get-files (vla-get-preferences (vlax-get-acad-object)))
   (strcat
       "Z:\ENGINEERING STANDARDS\Obsolete KDS Standards\Standard Details;"
      "Z:\ENGINEERING STANDARDS\Obsolete KDS Standards\Standard Fixtures;"
      "Z:\ENGINEERING STANDARDS\Obsolete KDS Standards\Standard Fixtures;"
      "Z:\ENGINEERING STANDARDS\Piping Symbols;"
      "Z:\ENGINEERING STANDARDS\Standard Details;"
      "Z:\ENGINEERING STANDARDS\Standard Fixtures;"
      "Z:\ENGINEERING STANDARDS\Standard Legends;"
      "Z:\ENGINEERING STANDARDS\Standard Schedules;"
   )
)

;(load "Z:\AUTODESK_TEMPLATES\Softwares - Do Not Delete\enu 4 AutoCad_MEP 2014\Copy & Paste to User_Roaming\enu\piping-new2014rev4.cuix")
;(load "Z:\AUTODESK_TEMPLATES\Softwares - Do Not Delete\enu 4 AutoCad_MEP 2014\Copy & Paste to User_Roaming\enu\KDS-Fixtures-Rev1.cuix")


^C^C^P(command "menuunload" "KDS-Fixtures-Rev1" "_.menuload" "Z:\AUTODESK_TEMPLATES\Softwares - Do Not Delete\enu 4 AutoCad_MEP 2014\Copy & Paste to User_Roaming\enu\KDS-Fixtures-Rev1.cuix")

^C^C^P(command "menuunload" "piping-new2014rev4" "_.menuload" "Z:\AUTODESK_TEMPLATES\Softwares - Do Not Delete\enu 4 AutoCad_MEP 2014\Copy & Paste to User_Roaming\enu\piping-new2014rev4.cuix")

(command "cuiunload" "KDS-Fixtures-Rev1"  ^C "cuiload" "Z:\AUTODESK_TEMPLATES\Softwares - Do Not Delete\enu 4 AutoCad_MEP 2014\Copy & Paste to User_Roaming\enu\KDS-Fixtures-Rev1.cuix" ^C)
(command "cuiunload" "piping-new2014rev4" ^C "cuiload" "Z:\AUTODESK_TEMPLATES\Softwares - Do Not Delete\enu 4 AutoCad_MEP 2014\Copy & Paste to User_Roaming\enu\piping-new2014rev4.cuix" ^C)


(princ "KDS Newmenu utilities… Loaded.")
(Princ)


 

---T his is my error:

menuunload KDS-Fixtures-Rev1
Unknown Customizaton Group: KDS-Fixtures-Rev1
_.menuload Z:AUTODESK_TEMPLATESSoftwares - Do Not Deletenu 4 AutoCad_MEP 2014Copy & Paste to User_RoamingnuKDS-Fixtures-Rev1.cuix menuunload piping-new2014rev4 _.menuload Z:AUTODESK_TEMPLATESSoftwares - Do Not Deletenu 4 AutoCad_MEP 2014Copy & Paste to User_Roamingnupiping-new2014rev4.cuix cuiunload KDS-Fixtures-Rev1 cuiload Z:AUTODESK_TEMPLATESSoftwares - Do Not Deletenu 4 AutoCad_MEP 2014Copy & Paste to User_RoamingnuKDS-Fixtures-Rev1.cuix cuiunload piping-new2014rev4
Unknown Customizaton Group: piping-new2014rev4
Command: cuiload
Enter name of customization file to load: Z:AUTODESK_TEMPLATESSoftwares - Do Not Deletenu 4 AutoCad_MEP 2014Copy & Paste to User_Roamingnupiping-new2014rev4.cuix
Enter name of customization file to load: KDS Newmenu utilities… Loaded.
AutoCAD menu utilities loaded.
AutoCAD MEP menu utilities loaded.
AutoCAD Architecture menu utilities loaded.*Cancel*
Autodesk DWG.  This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application.
Command:
Command:
Command: _ToolPalettes
0 Likes
Accepted solutions (1)
1,642 Views
2 Replies
Replies (2)
Message 2 of 3

DannyNL
Advisor
Advisor
Accepted solution

First of all, you should check if the menu name is the same as the filename.

CUIUNLOAD expects the menugroup name, while CUILOAD expects a .CUIX file. These can be different. A menu file with the name X.CUIX can have a menugroup name Y.

 

And you should only load when the file is not loaded. Just unloading and loading can mess up your workspace, so it is not preferable.

 

You can check if a menugroup is loaded with MENUGROUP and load only if the menu is not yet loaded. Also make sure to use \\ or / in the path names as \ indicates a special character in LISP. So in example assuming the menugroup name is the same as the filename:

 

(if
   (not (menugroup "KDS-Fixtures-Rev1"))
   (command "cuiload" "Z:\\AUTODESK_TEMPLATES\\Softwares - Do Not Delete\\enu 4 AutoCad_MEP 2014\\Copy & Paste to User_Roaming\\enu\\KDS-Fixtures-Rev1.cuix"
   )
)

Instead of CUILOAD you can also use MENULOAD.

0 Likes
Message 3 of 3

fawzimasri7137
Advocate
Advocate

Thanks for the response, ..

 

yes, i did realize i had few syntax issues in my code and i have fixed.  so now it works for 2015 thru 2017.

 

i still have some issues in 2018.  it loads the file and you can see them in CUILOAD dialog, but you can't find them in the menu.  i will submit another question once i spend some more time on it.

 

here is my current code:

(vl-load-com)
(vla-put-supportpath
   (vla-get-files (vla-get-preferences (vlax-get-acad-object)))
   (strcat
      "Z:\ENGINEERING STANDARDS\Obsolete KDS Standards\Standard Details;"
      "Z:\ENGINEERING STANDARDS\Obsolete KDS Standards\Standard Fixtures;"
      "Z:\ENGINEERING STANDARDS\Obsolete KDS Standards\Standard Fixtures;"
      "Z:\ENGINEERING STANDARDS\Piping Symbols;"
      "Z:\ENGINEERING STANDARDS\Standard Details;"
      "Z:\ENGINEERING STANDARDS\Standard Fixtures;"
      "Z:\ENGINEERING STANDARDS\Standard Legends;"
      "Z:\ENGINEERING STANDARDS\Standard Schedules;"
   )
)



(princ "Start  Of KDS cuix acad.lsp !!")
;;^C^C^P(command "menuunload" "KDS-Fixtures-Rev1" "_.menuload" "Z:\AUTODESK_TEMPLATES\Softwares - Do Not Delete\enu 4 AutoCad_MEP 2014\Copy & Paste to User_Roaming\enu\KDS-Fixtures-Rev1.cuix")

(IF (= nil (menugroup "KDS-Fixtures-Rev1"))(command "cuiload" "Z:\\AUTODESK_TEMPLATES\\Softwares - Do Not Delete\\enu 4 AutoCad_MEP 2014\\Copy & Paste to User_Roaming\\enu\\KDS-Fixtures-Rev1.cuix"))

(IF (= nil (menugroup "piping-new2014rev4"))(command "cuiload" "Z:\\AUTODESK_TEMPLATES\\Softwares - Do Not Delete\\enu 4 AutoCad_MEP 2014\\Copy & Paste to User_Roaming\\enu\\piping-new2018-R1.cuix"))


(princ "End Of KDS cuix acad.lsp !!")
(Princ)


thanks

0 Likes