Results 1 to 4 of 4

Thread: wcmatching a list

  1. #1
    100 Club
    Join Date
    2012-11
    Posts
    105

    Default wcmatching a list

    Hey guys

    I am trying to do a wildcard match of everyline of a list and if it contains *-H-* remove it from the list.
    despite my best efforts i cant seem to overcome this hurdle...
    the goal is to remove all the hydraulic(*-H-*) drawings from the list
    here is an example of the name:
    M13536-M-L06-101.dwg
    M13536-H-L06-101.dwg
    M13536-E-L06-201.dwg

    this is my attempt:

    Code:
    (defun C:MMCoord (/)
     (setq  dwgpath  (getvar "dwgprefix")
      dwgname  (if (= (strlen (getvar "dwgname")) 20)
          (getvar "dwgname")
          (exit)
        )
      discipline (substr dwgname 8 1)
      level   (substr dwgname 10 3)
      namelist (vl-directory-files dwgpath (strcat "*-*-" level "-*.dwg") 1)
     )
     (setq dwgnamelist (foreach temp1 namelist
         (lambda (temp1)
          (if
           (= nil (wcmatch temp1 "*-H-*"))
           (list temp1)
           (nil)
          )
         )
        )
     )
    princ dwgnamelist
    )
    Im pretty new to lisp so any advice on my coding would be greatly appreciated.

    Cheers
    Last edited by Opie; 2013-01-08 at 01:59 PM. Reason: [code] tags added ~Opie

  2. #2
    I could stop if I wanted to pbejse's Avatar
    Join Date
    2010-10
    Posts
    398

    Default Re: wcmatching a list

    Code:
    (foreach itm namelist
          (if (wcmatch itm "*-H-*")
              		(setq namelist (vl-remove itm namelist))))
    or

    Code:
    (vl-remove-if '(lambda (k)
                             (wcmatch k "*-H-*")) namelist)
    Please use CODE Tags

    [ CODE ] (defun ....) [ / CODE ] ;<-- without the space " "
    Last edited by pbejse; 2013-01-08 at 08:04 AM.

  3. #3
    I could stop if I wanted to Tharwat's Avatar
    Join Date
    2010-06
    Posts
    478

    Default Re: wcmatching a list

    Pbe , you may need add a space between the variable and the wcmatch string , although it does not hurt .

  4. #4
    I could stop if I wanted to pbejse's Avatar
    Join Date
    2010-10
    Posts
    398

    Default Re: wcmatching a list

    Quote Originally Posted by Tharwat View Post
    Pbe , you may need add a space between the variable and the wcmatch string , although it does not hurt .
    Of course tharwat, context is everything after all
    Last edited by pbejse; 2013-01-08 at 09:18 AM.

Similar Threads

  1. Annotation Scale list keeps propagating the whole list
    By jacep in forum AutoCAD Annotation
    Replies: 16
    Last Post: 2007-12-13, 05:24 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, 01:15 AM
  3. Replies: 8
    Last Post: 2006-12-27, 01:05 PM
  4. Change list of cities in place list
    By janunson in forum Revit Architecture - General
    Replies: 2
    Last Post: 2005-05-10, 09:27 PM

Posting Permissions

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