VL-sort help

VL-sort help

DC-MWA
Collaborator Collaborator
537 Views
4 Replies
Message 1 of 5

VL-sort help

DC-MWA
Collaborator
Collaborator

Anybody know why this misses sheet "A0.00 - Title Sheet.dwg"

 

(setq dwgs (cdr (vl-sort (vl-remove-if-not
'(lambda (x) (wcmatch (strcase x) "A*.*.DWG"))
(vl-directory-files (getvar 'dwgprefix))
) ;_ vl-remove-if-not
'<
) ;_ vl-sort
)
) ;_ setq

 

0 Likes
Accepted solutions (1)
538 Views
4 Replies
Replies (4)
Message 2 of 5

SAPER59
Advocate
Advocate

I tested with my own list  (I don't have your directory) and don't miss it

(setq ldir (list "A0.00 - Title Sheet.dwg"
"A1.00 - Title Sheet.dwg"
"A2.00 - Title Sheet.dwg"
"A0.00 - Title Sheet.dwg"
"My dwg1.dwg"
"My dwg2.dwg"
)
)

SAPER59_0-1632525372075.png

 

 

Are you sure file name is that you wrote?

 It would be a good idea you update the list of your directory

0 Likes
Message 3 of 5

SAPER59
Advocate
Advocate

Sorry I forgot, you have a CDR at the beginig and loose first element of result list

 

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@DC-MWA wrote:

Anybody know why this misses sheet "A0.00 - Title Sheet.dwg"

 

(setq dwgs

  (cdr

    (vl-sort

      (vl-remove-if-not
        '(lambda (x) (wcmatch (strcase x) "A*.*.DWG"))
        (vl-directory-files (getvar 'dwgprefix))
      ) ;_ vl-remove-if-not
      '<
    ) ;_ vl-sort
  ); cdr
) ;_ setq


If it "hits" other similar drawing names, it's probably because "A0.00..." surely comes up first in such a sorted list, and the (cdr) function removes the first item.

Kent Cooper, AIA
0 Likes
Message 5 of 5

DC-MWA
Collaborator
Collaborator

Thank you.

0 Likes