francine2013 Posted August 4, 2022 Posted August 4, 2022 Hello everybody, I would like to work with a colleague via one drive and I have a lisp to redefine all block from different folders. The problem that I have is, using One Drive, the path of my blocks is not the same for both. Is it possible to add, in lisp, an environment variable to avoid this problem? Part of my lisp: (setq G:LISTDIR (list "C:\Users\username\OneDrive\.....\01_Profiles" "C:\Users\username\OneDrive\...\02_Gaskets" ) For example on my computer I would add the environment variable : username = francine2013 Quote
mhupp Posted August 4, 2022 Posted August 4, 2022 (edited) (strcat (getenv "userprofile") "\\OneDrive\\.....\\01_Profiles") --edit in windows explorer its %USERPROFILE% Edited August 4, 2022 by mhupp 1 Quote
francine2013 Posted August 4, 2022 Author Posted August 4, 2022 Thank a lot It works fine in the first lisp but in another one where I search for blocks I get an error message : error: bad argument type: stringp (STRCAT (GETENV "userprofile") "\\OneDrive.... Part of this lisp: (defun findblock ( dwg ) (vl-some '(lambda ( p ) (findfile (strcat p dwg))) '( "" (strcat (getenv "userprofile") "\\OneDrive\\....\\01_Profiles\\") (strcat (getenv "userprofile") "\\OneDrive\\....\\02_Gaskets\\") ))) Quote
tombu Posted August 4, 2022 Posted August 4, 2022 16 minutes ago, francine2013 said: Thank a lot It works fine in the first lisp but in another one where I search for blocks I get an error message : error: bad argument type: stringp (STRCAT (GETENV "userprofile") "\\OneDrive.... Part of this lisp: '( "" (strcat (getenv "userprofile") "\\OneDrive\\....\\01_Profiles\\") (strcat (getenv "userprofile") "\\OneDrive\\....\\02_Gaskets\\") ))) The " quote doesn't evaluate list items like the list (AutoLISP) function does, you need to use list instead. Lee Mac explains The Apostrophe and the Quote Function pretty well. 2 Quote
francine2013 Posted August 4, 2022 Author Posted August 4, 2022 Thanks A bit complicated for my lisp notions, but I'll try 1 Quote
francine2013 Posted August 4, 2022 Author Posted August 4, 2022 I've found a way to make it work but it's more by luck and your guidance. Thanks again. Part of this lisp: (defun findblock ( dwg ) (vl-some '(lambda ( p ) (findfile (strcat p dwg))) (list (strcat (getenv "userprofile") "\\OneDrive\\....\\01_Profiles\\") (strcat (getenv "userprofile") "\\OneDrive\\....\\02_Gaskets\\") ))) 1 Quote
mhupp Posted August 4, 2022 Posted August 4, 2022 in laymen terms what tombu is saying '((strcat (getenv "userprofile") "\\OneDrive\\....\\01_Profiles\\") (strcat (getenv "userprofile") "\\OneDrive\\....\\02_Gaskets\\")) with the ' it only outputs what is in the list strcat (getenv "userprofile") "\\OneDrive\\....\\01_Profiles\\" strcat (getenv "userprofile") "\\OneDrive\\....\\02_Gaskets\\" (list (strcat (getenv "userprofile") "\\OneDrive\\....\\01_Profiles\\") (strcat (getenv "userprofile") "\\OneDrive\\....\\02_Gaskets\\")) where list runs the starcat and getenv funtions to output C:\\Users\\username\\OneDrive\\....\\01_Profiles\\ C:\\Users\\username\\OneDrive\\....\\02_Gaskets\\ 2 Quote
Steven P Posted August 4, 2022 Posted August 4, 2022 7 minutes ago, francine2013 said: Thanks A bit complicated for my lisp notions, but I'll try Anything after a '( is a fixed list, CAD will take it as it is, anything after (list and CAD will try to calculate this list For example '( 1 2 3 4 5) is a list, 1 2 3 4 5 '(1 (+ 8 9) 3 4 5) is also a list 1 (+ 8 9) 3 4 5, and will probably be an error since it thinks the + is text, and wants it as "+" (list 1 2 3 4 5) is also a list 1 2 3 4 5 (list 1 (+ 8 9) 3 4 5 is a list 1 17 3 4 5, noting that the 8+9 has been calculated now That's the basic difference Remember to define any lists within your list as a list too In your case '( "" (strcat (getenv "userprofile") "\\OneDrive\\....\\01_Profiles\\") (strcat (getenv "userprofile") "\\OneDrive\\....\\02_Gaskets\\") ) this list is seen as all text items, errors for example (strcat CAD wants that to be a text string "(strcat....) Make it up as (list "" (strcat (getenv "userprofile") "\\OneDrive\\....\\01_Profiles\\") (strcat (getenv "userprofile") "\\OneDrive\\....\\02_Gaskets\\") ) and it should work it all out. Lee Macs description is better than mine 3 1 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.