TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GDF on April 18, 2020, 10:12:27 AM

Title: Using a wildcard to select a drawing
Post by: GDF on April 18, 2020, 10:12:27 AM
I'm trying to select a drawing file using a wildcard name within a directory without using the getfiled dialog box.

(setq *Xref* (getfiled "Select a File to Xref" "*BasePlan*.dwg" "*" 4))

Any ideas?
Title: Re: Using a wildcard to select a drawing
Post by: GDF on April 18, 2020, 10:34:58 AM
I got  this to work, but it's not what I'm looking for:

(cond
    ((= (substr (vl-string-right-trim ".dwg" (getvar 'dwgname)) 18 1) "L")
      (setq *Xref* (strcat (getvar "DwgPrefix")(substr (vl-string-right-trim ".dwg" (getvar 'dwgname)) 1 16) "DRH-BasePlan-L.dwg")))
    ((= (substr (vl-string-right-trim ".dwg" (getvar 'dwgname)) 18 1) "R")
      (setq *Xref* (strcat (getvar "DwgPrefix")(substr (vl-string-right-trim ".dwg" (getvar 'dwgname)) 1 16) "DRH-BasePlan-R.dwg")))
  )
Title: Re: Using a wildcard to select a drawing
Post by: Dlanor on April 18, 2020, 10:46:18 AM
This worked for me. List of files matching

Code - Auto/Visual Lisp: [Select]
  1. (setq dir "D:\\Autocad Files\\Lisp\\test_dwgs\\test\\" ext "*BasePlan*.dwg")
  2. (setq flst (vl-directory-files dir ext 1))
  3.  
Title: Re: Using a wildcard to select a drawing
Post by: GDF on April 18, 2020, 10:58:23 AM
Perfect|

Thank you sir
Title: Re: Using a wildcard to select a drawing
Post by: GDF on April 18, 2020, 11:10:15 AM
This is what I'm using:

(setq *Xref* (strcat (getvar "DwgPrefix")(car (vl-directory-files (getvar "DwgPrefix") "*BasePlan*.dwg" 1))))