Jump to content

Recommended Posts

Posted

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

Posted (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 by GLAVCVS
Posted (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 by GLAVCVS
Posted (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 by ronjonp
Posted

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")

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...