I had help building this section of code from other (distinguished) members in this community
therefore, I will share what I have to you.
Discovering if the desired POP is visible and displaying the desired POP is two completely
different animals. What is required for the display is both the POP's Element ID and the
POP's Alias Name. You will need to discover these items. I believe there might be a menu
name prefix that is also needed [MenuName.PopAliasName] when displaying(?).
The function below takes an argument, which is the POP Alias Name (one of them as there
might be several).
You may need to sort thru this and tailor to your needs as this was designed as
"Drawing Mode Switching" where the current mode's POP can be placed anywhere
in the menubar, yet allow swapping to another mode at that position. It will also remove strays.
;;
;;==== FUNCTION Set Dwg Mode Menu Bar POP (also removes stray DM POP's) =====
;; Argument is [POP alias name].
(defun XXXX-POP ( a / b f n ELID )
(setq b nil)
(vl-catch-all-apply (function (lambda ()
(vlax-for menu (vla-get-menubar (vlax-get-acad-object))
(setq b (cons (substr (vla-get-TagString menu) 9) b)) ;"Element ID"
))))
;*** For each "Drawing Mode" POP to be added, add the "Element ID" to this list. ***
(setq ELID (list "292C2" "11001" "B185C" "2225A" "9789C" "84D56" "91EE8" "126F2"
"E6690" "98056" "4A7AC" "21D28" "4FF39" "FED66" "EEB50" "B347F" "72FFA"))
(setq n 1 f nil)
(foreach x (reverse b)
(if (member x ELID)
(if (not f)
(progn (menucmd (strcat "P" (itoa n) "=" a))(setq f n)) ;swap menu
(progn (menucmd (strcat "P" (itoa f) "=-"))(setq f (1- f))) ;remove stray
);if
);if
(setq n (1+ n))
(if f (setq f (1+ f)))
);foreach
(if (not f) (menucmd (strcat "P" (itoa n) "=+" a))) ;display if none found
(setq b nil f nil n nil ELID nil)
);end XXXX-POP
;;
Background: Our previous menu had POP swapping at the 11th position regardless of what was there.
If one was to move the "Drawing Mode" POP to another position (say to the end, which is the 16th position),
what was at the 11th position would be swapped and the 16th position remained (resulting in two unique
Drawing Mode POP's). Removing the "Help" and "Parametric" POPs from the menubar would again disrupt
the position of the POP in which to swap.
???
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.