Scotth066 Posted March 27 Posted March 27 Once again, I need some help. I have a routine that extracts information from the document file path. My current folder structure is . . . SERVERNAME\Projects\2025 PROJECTS\25019-PROJECT NAME\CAD when i open my titleblock drawing, the routine extracts the project number (25019), finds the attribute "plan_#" and inserts that information. my problem is if there is a subfolder in the CAD folder (i.e. OPTION-01) , it extracts and inserts "CAD Is there a way to always extract the job number, in this case 25019. update-plan-number.lsp Quote
GLAVCVS Posted March 27 Posted March 27 (edited) Hi Scotth For example: replace '(vl-filename-base *job-folder*)' with... (nth 3 (foreach c (vl-string->list *job-folder*) (if (= (setq c (chr c)) "\\") (setq l (cons p l) p nil) (setq p (if p (strcat p c) c))) (if p (reverse (cons p l)) (reverse l)) ) ) Edited March 27 by GLAVCVS Quote
GLAVCVS Posted March 27 Posted March 27 (edited) Note: I've edited something. Make sure to use the current code. But if the search path will never change to the folder you're looking for, then simply count the number of characters up to the first folder number (considering "\\", if there is one, as only 1 character). So, if, for example, there are 35 characters, you'll get the number you want starting with the next character: 36, and you'll get it by typing: (substr *job_folder* 36 5) Edited March 28 by GLAVCVS Quote
ronjonp Posted March 27 Posted March 27 (edited) (setq path "SERVERNAME\\Projects\\2025 PROJECTS\\25019-PROJECT NAME\\CAD") (substr (repeat 3 (setq path (substr path (+ 2 (vl-string-search "\\" path))))) 1 5) No error checking... Edited March 27 by ronjonp Quote
BIGAL Posted March 27 Posted March 27 Another example. ; thanks to Lee-mac for this defun (defun csv->lst ( str / pos ) (if (setq pos (vl-string-position 126 str)) (cons (substr str 1 pos) (csv->lst (substr str (+ pos 2)))) (list str) ) ) (setq str "SERVERNAME\\Projects\\2025 PROJECTS\\25019-PROJECT NAME\\CAD") (while (if (= (wcmatch str "*\\*") T) (setq str (vl-string-subst "~" "\\"str 1)) ) ) (setq lst (csv->lst str)) ; ("SERVERNAME" "Projects" "2025 PROJECTS" "25019-PROJECT NAME" "CAD") 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.