AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

AutoCAD Setup

Let's imagine this scenario.
You've created a complex menu application complete with AutoLisp functions, Library files, Help files, Hatches, etc, etc. To load it yourself on your system is no problem. You know exactly which support paths need to be added, and exactly what menu file and pull down menu's need to be defined.
But now, you have 20 machines to load it on, or even worse, you need to send it to a third party to install on their system and you are not available. Now what? You could try and type the installation instructions out for them, but the users who will be installing your menu system don't even know where to find the "Options" dialog, never mind set support paths. This is where the following application will come in very handy.

It basically sets up a custom profile, adds your support paths, and then finds and loads your custom pull down menu.
Firstly the program creates a profile called "AfraLisp".
(That is if "AfraLisp" is not already the active profile.)
Don't worry, it retains your current profile so that you can re-set if necessary.
Secondly, it adds your support paths. I have used the following:

"C:/AfraLisp2002"
"C:/AfraLisp2002/Menu"
"C:/AfraLisp2002/CadLisp2k"
"C:/AfraLisp2002/CadLib2k"
"C:/AfraLisp2002/CadMech"
"C:/AfraLisp2002/Hatching"
"C:/AfraLisp2002/Help"
"C:/AfraLisp2002/Profiles"


Just replace the paths with your own. You will need to have these created and populated with your files on your hard drive.

Lastly, it locates and loads the "AfraLisp" menu file which is stored in "C:/AfraLisp2002/Menu" and places a pull down menu into the menu bar.
You will need to replace the "AfraLisp" with the name of your own partial menu.


;CODING STARTS HERE

(prompt "\nType \"AfraLisp-Install\" to run......")

(defun C:AfraLisp-Install ( / netpath defpath acadprofiles actprofile temp flag1)

(vl-load-com)

;retrieve the profiles collection
(setq acadprofiles 
	(vla-get-profiles 
		(vla-get-preferences 
			(vlax-get-Acad-Object))))

;get the active profile
(setq actprofile 
	(vla-get-ActiveProfile acadprofiles))

;check "AfraLisp" is the active profile
(if (not (= actProfile "AfraLisp"))

  (progn

    ;if it's not, copy the existing profile, renaming it "AfraLisp".
    (vlax-invoke-method acadProfiles 'CopyProfile actProfile "AfraLisp")

    ;then make it the active profile
    (vla-put-ActiveProfile acadProfiles "AfraLisp")

  );progn

);if

;;;=================================
;;;Set up the AfraLisp Support Paths

;set the path to the AfraLisp subdirectory.
(setq netpath "C:\\AfraLisp2002")

;set the support paths to the AutoCAD default
(setenv "ACAD" "")

;store the default paths
(setq defpath (getenv "ACAD"))

;set up the AfraLisp paths
(setenv "ACAD" (strcat 
defpath ";"
netpath ";"
netpath "\\" "Menu;"
netpath "\\" "CadLisp2k;"
netpath "\\" "CadLib2k;"
netpath "\\" "CadMech;"
netpath "\\" "Hatching;"
netpath "\\" "Help;"
netpath "\\" "Profiles;"
))

;set up the custom template path
(setenv "TemplatePath" (strcat netpath "\\" "Templates"))

;inform the user
(prompt "\nAfraLisp Support Paths Defined\n")

;;;================
;;;Now load the AfraLisp Menu

;set the flag
(setq flag1 T)

;check if the "AfraLisp" menu is loaded
(setq loaded (menugroup "AFRALISP"))

;if it's not
(if (= loaded nil)

   (progn

        ;find the menu file
        (setq temp (findfile "AFRALISP.MNU"))

           ;if it's found
           (if temp

   		(progn

		  (setvar "FILEDIA" 0)

                  ;load the "AfraLisp" menu
		  (command "menuload" "AFRALISP")

		  (setvar "FILEDIA" 1)

                  ;load the pulldown menu
		  (menucmd "P11=+AFRALISP.POP1")

                  ;Inform the user
       		  (prompt "\nLoading AfraLisp Custom Menu....\n")

		);progn

		(progn   

                 ;if it's NOT found, inform the user
                 (alert "Cannot Locate AfraLisp Menu.")
	
                 ;then clear the flag
		 (setq flag1 nil)

		);progn

	   );if

    );progn

);if

                ;if the menu is loaded
		(if flag1

                  ;inform the user 
      		  (prompt "\nAfraLisp Custom Menu Loaded....")

		);if

(princ)

);defun

(princ)

;CODING ENDS HERE
 
The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website