Welcome to CADTutor!
So you're wanting to replace the numbers in the file name, with that of the layer name(s)?
If all of the drawing names are two letters, followed by two numbers, then:
Code:(substr "AA11.dwg" 1 2)
Registered forum members do not see this ad.
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.
Welcome to CADTutor!
So you're wanting to replace the numbers in the file name, with that of the layer name(s)?
If all of the drawing names are two letters, followed by two numbers, then:
Code:(substr "AA11.dwg" 1 2)
"Potential has a shelf life." - Margaret Atwood




A bit more if say abc11 or asdfghh22 use "strlen" then subtract 2 and like Renderman
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.Code:(setq len (strlen dwgname)) (setq ans (substr 1 (- len 2)))
A man who never made mistakes never made anything
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Bookmarks