Search for filename variances.

Discussion in 'AutoCAD' started by BillZ, Feb 11, 2005.

  1. BillZ

    BillZ Guest

    R2005:

    I have a program that reads a text file from the main office.
    In this list are part numbers that correspond to drawing files of CNC parts.
    This is what the list of part nunbers looks like after I dompile my list of strings (lt1):
    37502
    3898
    58637
    58638
    58710
    58741
    60225
    60229
    63731
    70012
    2871
    35587
    39141
    54914
    54931
    54973
    5413
    58714
    77348
    77349
    77422
    77711
    26960
    3750
    39233
    66266
    69906
    69961
    69962
    77413

    I used to do a findfile to be sure that the part .dwg exists.
    (repeat (length lt1)
    (setq n (nth cnt lt1))
    (if (= (substr n 5 1) " ")
    (setq n (substr n 1 4))
    )
    (setq fl (findfile (strcat "G:\\Parts\\Drawing\\" n ".dwg"))
    cnt (1+ cnt))
    Do what ever here.

    We have recently changed all the part .dwg names. This is for another program we are supposed to switch over to in a week or so (now we've put it off until June).

    In the mean time our drawings are named:
    37502-05.dwg
    3898-05.dwg
    58637-06.dwg
    58638-05.dwg
    58710-06.dwg

    So how can I change my findfile so that using the number string "37502", I can check for drawing name 37502-05.dwg and if that's not there is will look for 37502-06.dwg ect?

    TIA

    Bill
     
    BillZ, Feb 11, 2005
    #1
  2. BillZ

    BillZ Guest

    I think I've found it:

    (vl-remove-if 'null (mapcar '(lambda (x)(findfile (strcat
    "G:\\Parts\\Drawing\\54973" x ".dwg")))(list "-05" "-06")))
    ("G:\\Parts\\Drawing\\54973-05.dwg")

    Thanks for any inconvenience.

    Bill
     
    BillZ, Feb 11, 2005
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.