Menu Loader
Loading partial men files can be a real pain. Having to first add all
the menu directories to the AutoCAD Support Path and then installing the
menu files becomes a real hassle, especially if you've got a number of
workstations to take care of.
Here's a little application that takes a lot of the pain out of
multiple standard menu installation.
I have used a small partial menu "Vbamenu.mnu" that contains one
pulldown menu and one toolbar as an example.
First, you need to have your support file directory structure set up
and ready :
c:/vbamenu
c:/vbamen/lisp
c:/vbamenu/vba
In this example you can see that I've set up my main
directory, "c:/vbamenu" with two sub-directories,
"lisp" and "vba."
My menu and lisp files, "vbamenu," "vba.dll," and
"vbamenu.lsp" are stored in "vbamenu," whilst I would
store any additional support files in the other two sub-directories.
In essence, these are the directories that I would need to add to my
AutoCAD support path.
Next, fire up AutoCAD and open a blank drawing.
Now type this at the command line :
(load "c:\\vbamenu\\vbamenu)
Then press "Enter"
A message should appear on the command line asking you to
type "vbamenu" to run.
Do just that and stand back.
Voila, you should have a new pull down menu and a new
toolbar.
Check out your support path. Three new directories should
have been added :
Heres the coding :
;inform the user how to run the application
(prompt "\nVBA Menu Installer Loaded...Type VBAMENU to run......")
;define the function
(defun C:VBAMENU ( / flag1 loaded temp)
;add the first support path
(addSupportPath "C:\\VBAMENU" 6)
;add the second
(addSupportPath "C:\\VBAMENU\\LISP" 7)
;add the third
(addSupportPath "C:\\VBAMENU\\VBA" 8)
;set the flag
(setq flag1 T)
;check if the menu is not already loaded
(setq loaded (menugroup "VBAMENU"))
;if it is not loaded
(if (= loaded nil)
;do the following
(progn
;find the menu file
(setq temp (findfile "VBAMENU.MNU"))
;if you find the menu
(if temp
;do the following
(progn
;switch off dialogues
(setvar "FILEDIA" 0)
;load the menu
(command "menuload" "VBAMENU")
;switch on dialogues
(setvar "FILEDIA" 1)
;install the pulldown
(menucmd "P11=+VBAMENU.POP1")
;inform the user
(prompt "\nLoading VBA Menu....\n")
);progn
;menu not find, so do the following
(progn
;inform the user
(alert "Cannot Locate VBA Menu.
\nCall System Administrator.")
;clear the flag
(setq flag1 nil)
);progn
);if
);progn
);if
;if the flag is set
(if flag1
;inform the user
(prompt "\nVBA Menu Loaded....\n")
);if
(princ)
);defun
;subroutine to add support path
(defun addSupportPath (dir pos / tmp c lst)
(setq tmp ""
c -1
)
(if
(not
(member (strcase dir)
(setq lst
(mapcar 'strcase
(parse (getenv "ACAD") ";")
)
);setq
);member
);not
(progn
(if (not pos)
(setq tmp (strcat (getenv "ACAD") ";" dir))
(mapcar '(lambda (x)
(setq tmp (if (= (setq c (1+ c)) pos)
(strcat tmp ";" dir ";" x)
(strcat tmp ";" x)
)
)
)
lst
)
)
(setenv "ACAD" tmp)
)
)
(princ)
)
;parsing routine
(defun parse (str delim / lst pos)
(setq pos (vl-string-search delim str))
(while pos
(setq lst (cons (substr str 1 pos) lst)
str (substr str (+ pos 2))
pos (vl-string-search delim str)
)
)
(if (> (strlen str) 0)
(setq lst (cons str lst))
)
(reverse lst)
)
(princ);clean load
A big thank you to ActiveX.com for
allowing me to borrow a wee bit of their coding.
To make sure that your menu is loaded every time AutoCAD starts, place
this coding in your Acad.Lsp file :
(defun-q VBAMENUSTARTUP ()
(setq flag1 T)
(setq loaded (menugroup "VBAMENU"))
(if (= loaded nil)
(progn
(setq temp (findfile "VBAMENU.MNU"))
(if temp
(progn
(setvar "FILEDIA" 0)
(command "menuload" "VBAMENU")
(setvar "FILEDIA" 1)
(menucmd "P11=+VBAMENU.POP1")
(prompt "\nLoading VBA Menu....\n")
);progn
(progn
(alert "Cannot Locate VBA Menu.
\nCall System Administrator.")
(setq flag1 nil)
);progn
);if
);progn
);if
(if flag1
(prompt "\nVBA Menu Loaded....\n")
);if
(princ)
);defun-q
(setq S::STARTUP (append S::STARTUP VBAMENUSTARTUP))
To download source coding - VbaMenu1.Zip (6kB) - click here |