Ross Dunkley Posted June 4, 2019 Share Posted June 4, 2019 Hi, I am running into problems with my program when I try to use the output from the "LM:directoryfiles" function. If I try to use the output from the "LM:directoryfiles" function (findjgw) I am getting the following error... error: bad argument type: (or stringp symbolp): ("L:\\DESIGN\\2018\\2018-290 Atkinson Crescent, ALDINGA BEACH\\Work in Progress CAD\\References CAD\\2018-290 Image\\2018-290 Image.jgw") (findjgw) returns the following "L:\\DESIGN\\2018\\2018-290 Atkinson Crescent, ALDINGA BEACH\\Work in Progress CAD\\References CAD\\2018-290 Image\\2018-290 Image.jgw" and if I enter this actual text string in my code it works, but it wont when referring to the variable (findjgw). Is it because I am trying to use a list as a string? If I only use the first element of a list are they not the same thing? Snippet that seems to be thew problem... ; Search Project "References CAD" Folder for ".jgw" files and Count how many... (setq rcpath (strcat sfpath "Work in Progress CAD\\References CAD\\")) (setq findjgw (LM:directoryfiles rcpath "*.jgw" T)) (setq countjgw (length findjgw)) (cond ( (= countjgw 1) (princ "\nOnly 1 Georeferenced Aerial Image exists in 'References CAD folder'") (setq jpgname (vl-string-subst "jpg" "jgw" findjgw)) (setq intFileDia (getvar "filedia")) (setvar "filedia" 0) (command "mapiinsert" jpgname "") (command "zoom" "e") (setvar "filedia" intFileDia) (princ "\nGeoreferenced Aerial Imagery Inserted...") ) ( (> countjgw 1) (alert "More than 1 Georeferenced Aerial Image exists in 'References CAD folder'...\nPlease select file to insert...") (command "mapiinsert") (princ) ) (t nil) );End Cond I will attach the full copy also. Regards, Ross. ONK Mapiinsert 4.lsp Quote Link to comment Share on other sites More sharing options...
Emmanuel Delay Posted June 4, 2019 Share Posted June 4, 2019 First impression: the problem is here: findjgw is a list, (vl-string-subst expects a string there. (setq jpgname (vl-string-subst "jpg" "jgw" findjgw)) This should work: (setq jpgname (vl-string-subst "jpg" "jgw" (nth 0 findjgw ))) 1 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted June 4, 2019 Share Posted June 4, 2019 One thing I see that could cause an issue is 11 hours ago, Ross Dunkley said: Is it because I am trying to use a list as a string? If I only use the first element of a list are they not the same thing? Yes .. you cannot pass a list to vl-string-subst. Use (car findjgw). Also your UNC path check could be simplified to this: (if (wcmatch (getvar 'dwgprefix) "\\*") "UNC" "MAPPED" ) Just guessing, but this looks like an incorrect path too. (setq sfpath (strcat "\\\\" drive "\\" dir1 "\\" dir2 "\\" dir3 "\\" dir4 "\\")) 1 Quote Link to comment Share on other sites More sharing options...
Ross Dunkley Posted June 5, 2019 Author Share Posted June 5, 2019 Thanks guys! The following line did the trick... (setq jpgname (vl-string-subst "jpg" "jgw" (car findjgw))) Quote Link to comment Share on other sites More sharing options...
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.