So my current project requires a different profile and menu system.
I am trying to have a toggle within the menu to be able to unload one profile and switch to another profile.
I am able to get the current profile (getvar "cprofile") to be switched with no problem but what i'm having issues with is bringing in the CUI MENU when the profile gets switched.
If anyone has a working routine to do this please share, here's what I've managed to piece together so far and is working at about 80% expectancy, i need it 100%
(vl-load-com)
;; Add Support File Search Paths at 'n' - Lee Mac ;; Adds a list of Support File Search Paths, excluding duplicates and invalid paths. ;; lst - [lst] list of paths to add, e.g. '("C:\\Folder1" "C:\\Folder2" ... ) ;; idx - [int] [optional] zero-based index at which to add new paths ;; Returns: [str] "ACAD" Environment String following modification
(defun LM:sfsp+n ( lst idx / add str )
(defun add ( str new idx / pos ) (if (< 0 idx) (if (setq pos (vl-string-position 59 str)) (strcat (substr str 1 (1+ pos)) (add (substr str (+ pos 2)) new (1- idx))) (strcat ";" new) ) (strcat new str ";") ) )
(setenv "ACAD" (add (setq str (vl-string-right-trim ";" (getenv "ACAD"))) (apply 'strcat (mapcar '(lambda ( x ) (strcat x ";")) (vl-remove-if '(lambda ( x ) (or (vl-string-search (strcase x) (strcase str)) (not (findfile x)) ) ) (mapcar '(lambda ( x ) (vl-string-right-trim "\\" (vl-string-translate "/" "\\" x)) ) lst ) ) ) ) idx ) ) )
(defun menu_load ( / menu_path menu_name group_name )
(if (= "L-CONPID" (getvar "cprofile"))
(command "menuunload" "pip")
);if
(LM:sfsp+n '("Y:\\L-con PID\\PIP" "Y:\\L-Con PID\\PathFolder" "Y:\\L-Con PID" "Y:\\L-con PID\\PIP\\misc") 0)
(vla-put-ActiveProfile
(vla-get-Profiles
(vla-get-Preferences
(vlax-get-acad-object))
) "PIP" )
;; Save this file as 'Menu_Load.lsp', in your support folder.
;; To Automatically Load the target 'pop' menu..
;; -- in your acaddoc.lsp, do: (load "Menu_Load.lsp")
;; Replace next line with your 'real' Drive/path to the file
(setq Menu_Path "Y:\\L-Con PID\\PIP\\"); Path to Menu file
(setq Menu_Name "PIP"); pop menu to load
(setq Group_Name "PIP"); groupname assigned
;; Load Pop Menu
(if (findfile (strcat Menu_Path Menu_Name ".cuix"))
(progn
(if (/= (menugroup Group_Name) nil)
(command "_MENUUNLOAD" Group_Name)
); end if
(if (= (menugroup Group_Name) nil)
(progn
(command "_MENULOAD" (strcat Menu_Path Menu_Name))
;; note: in next line, replace P2 with desired Position in Menu Bar
(menucmd (strcat "P13=+" Group_Name ".POP13"))
); end progn ); end if ); end progn ); end if
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;back to l-con profile;;;;;;;;;;;;;;;;;
(defun menu_load2 ( / menu_path2 menu_name2 group_name2 )
(command "menuunload" "L-CONPID")
(LM:sfsp+n '("Y:\\L-con PID\\PIP" "Y:\\L-Con PID\\PathFolder" "Y:\\L-Con PID" "Y:\\L-con PID\\PIP\\misc") 0)
(vla-put-ActiveProfile
(vla-get-Profiles
(vla-get-Preferences
(vlax-get-acad-object))
) "L-CONPID" )
;; Save this file as 'Menu_Load.lsp', in your support folder.
;; To Automatically Load the target 'pop' menu.. ;; -- in your acaddoc.lsp, do: (load "Menu_Load.lsp")
;; Replace next line with your 'real' Drive/path to the file
(setq Menu_Path2 "Y:\\L-Con PID\\"); Path to Menu file
(setq Menu_Name2 "L-CONPID"); pop menu to load
(setq Group_Name2 "L-CONPID"); groupname assigned
;; Load Pop Menu
(if (findfile (strcat Menu_Path2 Menu_Name2 ".cuix"))
(progn
(if (/= (menugroup Group_Name2) nil)
(command "_MENUUNLOAD" Group_Name2)
); end if (if (= (menugroup Group_Name2) nil)
(progn
(command "_MENULOAD" (strcat Menu_Path2 Menu_Name2))
;; note: in next line, replace P2 with desired Position in Menu Bar
(menucmd (strcat "P13=+" Group_Name2 ".POP13"))
); end progn ); end if ); end progn ); end if
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(defun c:pippro (/ cpr menu_path menu_path2 Menu_name Menu_name2 group_name group_name2) ;
(if (= (getvar "cprofile") "PIP") ;
(setq cpr "L-CONPID") ;
(setq cpr "PIP") ;
) ;
(if (= cpr nil) ;
(setq cpr "L-CONPID") ;
) ;
(vla-put-ActiveProfile ;
(vla-get-Profiles ;
(vla-get-Preferences
(vlax-get-acad-object)) ;
) ;
cpr ; )
;(cond
;((= "L-CONPID" (getvar "cprofile")) ;
(princ "\nSwitching to PIP profile....")
(menu_load))
;((= "PIP" (getvar "cprofile")) ;
(menu_load2)(princ "\nSwitching to L-Con PID profile....")(princ))
;);cond ;
) ;_defun
Thanks in advance for any insights into solving this slight issue.
Solved! Go to Solution.
Solved by bhull1985. Go to Solution.
Okay i was pretty close....believe i have it working now...thanks anyhow!