MarcoW Posted April 26, 2010 Posted April 26, 2010 Click this link to see the whole routine: http://www.afralisp.net/archive/vl/acadset.htm THis part is where my question is: ;;;================================= ;;;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") ;;;================ How would I modify the code so my current search paths remain asthey are, so the new paths are to be added? I am in the middle of something but whenever I execute the routine, it copies the profile like it should but the SFSP's are overwritten with the new ones? Sorry if I am not totally clear... my goal is to keep the SFSP and ADD the new ones, not loose the old ones. Any help is appreciated, as allways. BTW: all credits to AfraLisp of course!! Quote
lpseifert Posted April 26, 2010 Posted April 26, 2010 Have a look here on how to add a folder to your support path http://www.afralisp.net/visual-lisp/tutorials/beginning-visual-lisp-part-2.php Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 Here's one I compiled for work... (defun c:CES-Setup (/ #Files #Layout #Flag) (vl-load-com) (and (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda () (setq #Files (vla-get-files (vla-get-preferences (vlax-get-acad-object)) ) ;_ vla-get-files #Layout (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)) ) ;_ vla-get-activelayout ) ;_ setq ;; ********************* ;; ** AutoSave Path ** ;; ********************* (mapcar 'vl-mkdir (list "c:\\TEMP" "c:\\TEMP\\ACAD")) (vla-put-autosavepath #Files "c:\\TEMP\\ACAD") ;; *************************** ;; ** Printer Config Path ** ;; *************************** (vla-put-PrinterConfigPath #Files "s:\\cadd standards\\Plotters" ) ;_ vla-put-PrinterConfigPath (vla-refreshplotdeviceinfo #Layout) ;; *********************** ;; ** Plotstyles Path ** ;; *********************** (vla-put-printerstylesheetpath #Files "s:\\cadd standards\\Plotstyles" ) ;_ vla-put-printerstylesheetpath (vla-refreshplotdeviceinfo #Layout) ;; ********************* ;; ** Template Path ** ;; ********************* (vla-put-TemplateDwgPath #Files "s:\\cadd standards\\Template" ) ;_ vla-put-TemplateDwgPath ;; ********************* ;; ** QNew Template ** ;; ********************* (vla-put-QNewTemplateFile #Files "s:\\cadd standards\\Template\\CES_Template.dwt" ) ;_ vla-put-QNewTemplateFile ;; ********************* ;; ** Support Paths ** ;; ********************* (vla-put-supportpath #Files (strcat ";s:\\cadd standards\\startup" ";s:\\cadd standards\\lisp" ";s:\\cadd standards\\linetypes" ";s:\\cadd standards\\fonts" ";s:\\cadd standards\\ces layers" ";" (vla-get-supportpath #Files) ) ;_ strcat ) ;_ vla-put-supportpath ;; *************************** ;; ** Tool Palettes Paths ** ;; *************************** (vla-put-ToolPalettePath #Files (strcat "S:\\CADD Standards\\Toolpalette\\Palettes;" (vla-get-ToolPalettePath #Files) ) ;_ strcat ) ;_ vla-put-ToolPalettePath ) ;_ lambda ) ;_ vl-catch-all-apply ) ;_ vl-catch-all-error-p ) ;_ not (alert (strcat "AutoCAD has been setup for Capital Engineering & Surveying, Inc. Standards.\n\n" " Please restart AutoCAD." ) ;_ strcat ) ;_ alert ) ;_ and (princ) ) ;_ defun (alert "Type: \"CES-SETUP\" to run setup.") (princ) Quote
MarcoW Posted April 26, 2010 Author Posted April 26, 2010 Thanks guys!! Now let me do some homework tonight!! Quote
MarcoW Posted April 26, 2010 Author Posted April 26, 2010 Here's one I compiled for work... (defun c:CES-Setup (/ #Files #Layout #Flag) (vl-load-com) (and (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda () (setq #Files (vla-get-files (vla-get-preferences (vlax-get-acad-object)) ) ;_ vla-get-files #Layout (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)) ) ;_ vla-get-activelayout ) ;_ setq ;; ********************* ;; ** AutoSave Path ** ;; ********************* (mapcar 'vl-mkdir (list "c:\\TEMP" "c:\\TEMP\\ACAD")) (vla-put-autosavepath #Files "c:\\TEMP\\ACAD") ;; *************************** ;; ** Printer Config Path ** ;; *************************** (vla-put-PrinterConfigPath #Files "s:\\cadd standards\\Plotters" ) ;_ vla-put-PrinterConfigPath (vla-refreshplotdeviceinfo #Layout) ;; *********************** ;; ** Plotstyles Path ** ;; *********************** (vla-put-printerstylesheetpath #Files "s:\\cadd standards\\Plotstyles" ) ;_ vla-put-printerstylesheetpath (vla-refreshplotdeviceinfo #Layout) ;; ********************* ;; ** Template Path ** ;; ********************* (vla-put-TemplateDwgPath #Files "s:\\cadd standards\\Template" ) ;_ vla-put-TemplateDwgPath ;; ********************* ;; ** QNew Template ** ;; ********************* (vla-put-QNewTemplateFile #Files "s:\\cadd standards\\Template\\CES_Template.dwt" ) ;_ vla-put-QNewTemplateFile ;; ********************* ;; ** Support Paths ** ;; ********************* (vla-put-supportpath #Files (strcat ";s:\\cadd standards\\startup" ";s:\\cadd standards\\lisp" ";s:\\cadd standards\\linetypes" ";s:\\cadd standards\\fonts" ";s:\\cadd standards\\ces layers" ";" (vla-get-supportpath #Files) ) ;_ strcat ) ;_ vla-put-supportpath ;; *************************** ;; ** Tool Palettes Paths ** ;; *************************** (vla-put-ToolPalettePath #Files (strcat "S:\\CADD Standards\\Toolpalette\\Palettes;" (vla-get-ToolPalettePath #Files) ) ;_ strcat ) ;_ vla-put-ToolPalettePath ) ;_ lambda ) ;_ vl-catch-all-apply ) ;_ vl-catch-all-error-p ) ;_ not (alert (strcat "AutoCAD has been setup for Capital Engineering & Surveying, Inc. Standards.\n\n" " Please restart AutoCAD." ) ;_ strcat ) ;_ alert ) ;_ and (princ) ) ;_ defun (alert "Type: \"CES-SETUP\" to run setup.") (princ) Alan, Maybe I cannot read it well enough but what is the difference between yours and mine? I mean, does yours add the paths? Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 Alan, Maybe I cannot read it well enough but what is the difference between yours and mine? I mean, does yours add the paths? Yes, it adds the paths. I took the Visual Lisp route as shown in Larry's link. Also, in addition to Support Paths, mine sets many others (eg. ToolPalette, Plotter Config., QNew Template, Template, etc.). Just look at the comment sections. Quote
MarcoW Posted April 26, 2010 Author Posted April 26, 2010 Yes, it adds the paths. Okay, that I could not see. I took the Visual Lisp route as shown in Larry's link. Since you (and maybe many others) have walked that way, I believe it might be a good way! Also, in addition to Support Paths, mine sets many others (eg. ToolPalette, Plotter Config., QNew Template, Template, etc.). Just look at the comment sections. I did read it Alan, and read the comments. Allready played with it, not succesfull but that will work out. I have a routine alike yours, but I do not need so many things to set. (I use toolpalettes and SFSP..) My problem is to add... like I said. Thank you very much for the response, I can go on for a while now Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 Okay, that I could not see. Since you (and maybe many others) have walked that way, I believe it might be a good way! I did read it Alan, and read the comments. Allready played with it, not succesfull but that will work out. I have a routine alike yours, but I do not need so many things to set. (I use toolpalettes and SFSP..) My problem is to add... like I said. Thank you very much for the response, I can go on for a while now It won't work if the paths do not exist. Even if it's more than you need, it gives you options on adding several others. Happy CAD'ing. Quote
MarcoW Posted April 26, 2010 Author Posted April 26, 2010 It work work if the paths do not exist. You mean it only works if the path exist, am I right? How come that this does not work: (vla-put-supportpath #Files (strcat "[size=4][color=blue][b];[/b][/color][/size]C:\\MarcoW" "[b][size=4][color=#0000ff];[/color][/size][/b]" (vla-get-supportpath #Files) ) ;_ strcat ) ... while the map "C:\MarcoW" does exist Another question, and maybe it has got something to do with it: What's up with the ";" in the code (what I made blue above). What does that thing do in the code? I ask because in my code it seems to be on the end of the line... Thanks for helping me out. Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 You mean it only works if the path exist, am I right?How come that this does not work: (vla-put-supportpath #Files (strcat "[size=4][color=blue][b];[/b][/color][/size]C:\\MarcoW" "[b][size=4][color=#0000ff];[/color][/size][/b]" (vla-get-supportpath #Files) ) ;_ strcat ) ... while the map "C:\MarcoW" does exist Another question, and maybe it has got something to do with it: What's up with the ";" in the code (what I made blue above). What does that thing do in the code? I ask because in my code it seems to be on the end of the line... Thanks for helping me out. What you posted works fine on my end. Actually, it added it without having the path created. As far as the semicolon goes, it's just to break to the next path (multiple paths). I just put it in the beginning because it just seemed a little cleaner/neater to put it first. It's just like using "\n" in a string. eg. (strcat "\nALAN" "\nThompson") = (strcat "\nALAN\n" "Thompson") Quote
MarcoW Posted April 27, 2010 Author Posted April 27, 2010 Alanjt, The code indeed works, it adds a support file search path! Thanks for the input, I might have shuffeld a bit around with those ";" thingies. There is not some code to prevent double paths, if you get what I mean. I tried it twice and I got the path "C:\temp" twice in the options dialog. Now let me try to figure it out allthough I have no clue how to start , as allways, I am a full time beginner, haha. Okay, but to start I stripped down the code so all I need is left (imagine me getting confused in such big routine LOL) (defun c:CES-Setup (/ #Files #Layout #Flag) (vl-load-com) (and (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda () (setq #Files (vla-get-files (vla-get-preferences (vlax-get-acad-object)) ) ;_ vla-get-files #Layout (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)) ) ;_ vla-get-activelayout ) ;_ setq [color=navy][b](mapcar 'vl-mkdir (list "c:\\TEMP" "c:\\TEMP\\ACAD"))[/b][/color] (vla-put-autosavepath #Files "c:\\TEMP\\ACAD") (vla-put-supportpath #Files (strcat ";c:\\temp" ";" (vla-get-supportpath #Files) ) ;_ strcat ) ;_ vla-put-supportpath ) ;_ lambda ) ;_ vl-catch-all-apply ) ;_ vl-catch-all-error-p ) ;_ not (alert (strcat "AutoCAD has been setup for Capital Engineering & Surveying, Inc. Standards.\n\n" " Please restart AutoCAD." ) ;_ strcat ) ;_ alert ) ;_ and (princ) ) ;_ defun (alert "Type: \"CES-SETUP\" to run setup.") (princ) (The blue part I now recognize, you know...) Somehow I would need toch check if one the current support file search folders matches one of the new ones. If they match than skip that one.... No really, I have no clue. Can you help me? Quote
alanjt Posted April 27, 2010 Posted April 27, 2010 Alanjt, The code indeed works, it adds a support file search path! Thanks for the input, I might have shuffeld a bit around with those ";" thingies. There is not some code to prevent double paths, if you get what I mean. I tried it twice and I got the path "C:\temp" twice in the options dialog. Now let me try to figure it out allthough I have no clue how to start , as allways, I am a full time beginner, haha. Okay, but to start I stripped down the code so all I need is left (imagine me getting confused in such big routine LOL) (defun c:CES-Setup (/ #Files #Layout #Flag) (vl-load-com) (and (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda () (setq #Files (vla-get-files (vla-get-preferences (vlax-get-acad-object)) ) ;_ vla-get-files #Layout (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)) ) ;_ vla-get-activelayout ) ;_ setq [color=navy][b](mapcar 'vl-mkdir (list "c:\\TEMP" "c:\\TEMP\\ACAD"))[/b][/color] (vla-put-autosavepath #Files "c:\\TEMP\\ACAD") (vla-put-supportpath #Files (strcat ";c:\\temp" ";" (vla-get-supportpath #Files) ) ;_ strcat ) ;_ vla-put-supportpath ) ;_ lambda ) ;_ vl-catch-all-apply ) ;_ vl-catch-all-error-p ) ;_ not (alert (strcat "AutoCAD has been setup for Capital Engineering & Surveying, Inc. Standards.\n\n" " Please restart AutoCAD." ) ;_ strcat ) ;_ alert ) ;_ and (princ) ) ;_ defun (alert "Type: \"CES-SETUP\" to run setup.") (princ) (The blue part I now recognize, you know...) Somehow I would need toch check if one the current support file search folders matches one of the new ones. If they match than skip that one.... No really, I have no clue. Can you help me? Yeah, I never bothered with checking for duplicates (no point) since it only gets run once on new installs. I would suggest using wcmatch to see if a string already exists in existing Support Paths. If it returns true, do nothing, if nil, add to Support Paths. I know you said you recognize the blue portion, but just to clarify, it was just to create the "c:\\temp\\acad" directory on the c:\ drive. BTW, you might want to remove all my company specific prompts/labels. LoL Quote
MarcoW Posted April 27, 2010 Author Posted April 27, 2010 I know you said you recognize the blue portion, but just to clarify, it was just to create the "c:\\temp\\acad" directory on the c:\ drive. Yes I know, but I just know it for a short while :wink: BTW, you might want to remove all my company specific prompts/labels. LoL I thought you liked that, ... no, I have forgotten.... I would suggest using wcmatch to see if a string already exists in existing Support Paths. If it returns true, do nothing, if nil, add to Support Paths. You say "if a string allready exists"... So with wcmatch I should be able to see if the string "c:\temp" is allready in the paths. But then the question how to do it. I mean, first I'd need to get all the supportfile paths in a list am I right? Quote
alanjt Posted April 27, 2010 Posted April 27, 2010 eg. (setq ExistingPaths ";c:\\folder1;c:\\folder2;c:\\folder3") (setq NewPaths (list "c:\\folder3" "c:\\folder4" "c:\\folder5")) (setq string "") (foreach x NewPaths (or (wcmatch ExistingPaths (strcat "*" x "*")) (setq string (strcat string ";" x)))) (vla-put-supportpath ... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.