Check if cui is loaded LISP

Check if cui is loaded LISP

Anonymous
Not applicable
1,297 Views
3 Replies
Message 1 of 4

Check if cui is loaded LISP

Anonymous
Not applicable

Hello guys

Can anyone send me the Lisp command to check if my menu "TestAPP" is loaded, if yes so unload it.
After that I will load it again.

The reason is, If I make an Update I just want to add the new .cuix File in same path and it should reload CUIX by everytime open AutoCAD.

 

I currently have this:
(vla-unload (vla-item (vla-get-menugroups (vlax-get-acad-object)) "TestAPP"))
(command "menuload" "C:\\Program Files\\Common Files\\TestAPP\\TestAPP.cuix")

 

The problem with this code is that if the user has never loaded "TestAPP" CUIX, AutoCAD gives an error that the unloading does not work.


Can anyone help me?

0 Likes
1,298 Views
3 Replies
Replies (3)
Message 2 of 4

Sea-Haven
Mentor
Mentor

Here is a start different method

 

(setq men (vla-get-menugroups (vlax-get-acad-object)))
(vlax-for meni men
(if (= (vla-get-name meni) "TESTAPP")
(alert "menu found")
(alert "menu not found")
)
)
0 Likes
Message 3 of 4

pbejse
Mentor
Mentor

@Anonymous wrote:

 

The problem with this code is that if the user has never loaded "TestAPP" CUIX, AutoCAD gives an error that the unloading does not work.


Can anyone help me?


 

 

Test if the menu is valid before unload/loading

 

(not
      (vl-catch-all-error-p
	(setq found (vl-catch-all-apply 'vla-item (list men "TestAPP")))
      )
    )

 

expertDelEtelogo.png

 

 

 

Message 4 of 4

ronjonp
Advisor
Advisor

Here's another ( untested ).

(defun c:foo (/ m mg r)
  (setq mg (vla-get-menugroups (vlax-get-acad-object)))
  (setq m "TestAPP")
  (if (= 'vla-object (type (setq r (vl-catch-all-apply 'vla-item (list mg m)))))
    (vla-unload r)
  )
  (command "_.menuload" (strcat "C:\\Program Files\\Common Files\\TestAPP\\" m ".cuix"))
  (princ)
)
0 Likes