+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Forum Newbie
    Using
    AutoCAD 2012
    Join Date
    May 2012
    Posts
    1

    Default Parsing out drawing name using LISP - please help

    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.

  2. #2
    Forum Deity BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    256GB SSD
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Using
    Civil 3D 2015
    Join Date
    Nov 2009
    Posts
    4,679

    Default

    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

    Autodesk Exchange Apps
    ~ Autoloader ~ AutoCAD Security

  3. #3
    Luminous Being
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    5,228

    Default

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

    Code:
    (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.
    A man who never made mistakes never made anything

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,815

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by BIGAL View Post
    ...pretty sure I have used a Lee Mac routine to get numbers from a string.
    Maybe:

    http://lee-mac.com/parsenumbers.html
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. open drawing using lisp
    By kalai in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 27th May 2012, 09:30 pm
  2. Error Parsing Xaml File
    By Autodesk in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 27th Dec 2010, 12:40 pm
  3. Parsing comma delimited file
    By Hudson in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 20th Oct 2009, 05:13 pm
  4. PARSING???
    By Dan in forum Design Software
    Replies: 1
    Last Post: 15th Jul 2003, 09:32 pm
  5. AutoCAD to Photoshop. Parsing????
    By Dan in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 21st Nov 2002, 10:08 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts