Kevin S Posted May 11, 2012 Share Posted May 11, 2012 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. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted May 11, 2012 Share Posted May 11, 2012 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: (substr "AA11.dwg" 1 2) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 15, 2012 Share Posted May 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 15, 2012 Share Posted May 15, 2012 ...pretty sure I have used a Lee Mac routine to get numbers from a string. Maybe: http://lee-mac.com/parsenumbers.html 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.