Results 1 to 4 of 4

Thread: Running a command for each line of a list.

  1. #1
    I could stop if I wanted to
    Join Date
    2012-11
    Location
    Brisbane, Australia
    Posts
    239
    Login to Give a bone
    0

    Default Running a command for each line of a list.

    Hey All

    I am trying to run a command to xref a list of files into a drawing but this is proving to be a little past my capabilities.

    Here is the code ive gotten so far.
    Any tips of better ways of achieving this would be appreciated, i think i may have taken a few long step to reach this point.

    Code:
    (defun C:MMCoord (/)
    ;(command "filedia" "0")
     (setq  dwgpath  (getvar "dwgprefix")       ;logs filepath
      dwgname  (if (= (strlen (getvar "dwgname")) 20)    ;logs drawing name
          (getvar "dwgname")     
          (exit)
        )
      discipline (substr dwgname 8 1)       ;logs discipline
      level   (substr dwgname 10 3)       ;logs level
      namelist (vl-directory-files dwgpath (strcat "*-*-" level "-*.dwg") 0)  ;logs list of drawings for matching level
      filter  (strcat "*-" discipline "-*,*-H-*,*-E-*-2*,*-C-*")   ;logs the drawing filter
     )
     (foreach temp1 namelist          ;refines drawing list with filter
      (if (wcmatch temp1 filter)
       (setq namelist (vl-remove temp1 namelist))
      )
     )
     (setq reflist nil)
     (foreach temp1 namelist          ;adds filepath to refined drawing list
      (setq reflist (cons (strcat dwgpath temp1) reflist))
     )
     (setq ListLength (length reflist))       ;logs list length
     (while (> listlength 0)          ;begins xref creation loop
      (setq overlay  (last reflist))
      (vl-remove overlay reflist)
      (command "-xref" "o" overlay "0,0,0" "" "" "")
      (- listlength 1)         ;fails miserably
     )
    ;(command "filedia" "1")
    princ overlay
    )
    Last edited by Opie; 2013-01-14 at 02:36 PM. Reason: [code] tags added ~Opie

  2. #2
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Running a command for each line of a list.

    I'm guessing this is related to your other posts

    http://forums.augi.com/showthread.ph...80#post1210280
    http://forums.augi.com/showthread.ph...ist-extraction

    You can do all that removing/rebuilding/filtering/processing with one foreach loop

    Code:
    (foreach temp1 namelist
              (If (not (wcmatch temp1 filter))
                  	(command "-xref" "o" (strcat dwgpath temp1)  "0,0,0" "" "" "")
                  )
              )
    HTH

  3. #3
    I could stop if I wanted to
    Join Date
    2012-11
    Location
    Brisbane, Australia
    Posts
    239
    Login to Give a bone
    0

    Default Re: Running a command for each line of a list.

    you sir are a legend!
    cheers mate

  4. #4
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Running a command for each line of a list.

    Quote Originally Posted by matthew.e.mortimer342462 View Post
    you sir are a legend!
    cheers mate
    Happy to help

    Cheers.

Similar Threads

  1. Running LISP command
    By KGC in forum AutoLISP
    Replies: 17
    Last Post: 2007-12-18, 11:01 PM
  2. LIST Command doesn't list Attached by Layer Materials
    By rbdome in forum AutoCAD 3D (2007 and above)
    Replies: 2
    Last Post: 2007-01-18, 02:15 AM
  3. Use LENGTHEN command to list Line length
    By dzatto in forum AutoCAD Tips & Tricks
    Replies: 2
    Last Post: 2007-01-02, 03:54 PM
  4. Replies: 8
    Last Post: 2006-12-27, 02:05 PM
  5. Auto running a command.
    By bobr.71433 in forum AutoCAD Customization
    Replies: 2
    Last Post: 2004-07-10, 01:59 AM

Posting Permissions

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