Jump to content

Parsing out drawing name using LISP - please help


Kevin S

Recommended Posts

Please help... I am trying to parse out drawing names and am struggling trying to get the names parsed out. Here's the senerio:

 

There's a long series of CAD files using a two letter - two number naming convention, like the following example:

AA11.dwg

AA22.dwg

BB11.dwg

BB22.dwg

...etc

 

Uses layers like:

X-NEW-01

X-EXIST-01

...etc

 

After some file manipulation using the numbers from the file name (11, 22, etc..), I need to be able to save out varients as:

AA-X-NEW-01.dwg

AA-X-EXIST-01.dwg

BB-X-NEW-01.dwg

BB-X-EXIST-01.dwg

...and so on.

Link to comment
Share on other sites

Welcome to CADTutor!

 

So you're wanting to replace the numbers in the file name, with that of the layer name(s)? :unsure:

 

If all of the drawing names are two letters, followed by two numbers, then:

 

(substr "AA11.dwg" 1 2)

Link to comment
Share on other sites

A bit more if say abc11 or asdfghh22 use "strlen" then subtract 2 and like Renderman

 

(setq len (strlen dwgname))
(setq ans (substr 1 (- len 2)))

 

If only 1 number character could do a check on 2nd last character and use - len 1 instead, keep doing for 123 etc pretty sure I have used a Lee Mac routine to get numbers from a string.

Link to comment
Share on other sites

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...