Jump to content

filtering layers (containing numbers) and to ignoring letters in layer names


Croftyno1

Recommended Posts

Afternoon Cadders,

 

I would like to ignore the letters when filtering the layers and only filter layers containing certain numbers ie, layer name : grid510, to be filtered by number 510 only, not by the whole layer name. Any suggestions welcome!!

This is the code what I currently use to filter my layers, courtesy of Lee Mack from a previous posted question.

 

(defun test ( / ss ) (vl-load-com)

 (if (setq ss (ssget (setq l '((8 . "ti grid re510,ti grid re520,ti grid re540,ti grid re560,ti grid re570,ti grid re580,ti grid tx150,ti grid type 1,ti grid type 2,ti grid type 3,ti grid type 4")))))
   (
     (lambda ( l / i e sym )
       (repeat (setq i (sslength ss))
         (ssadd (setq e (ssname ss (setq i (1- i))))
           (cond
             (
               (eval
                 (setq sym
                   (read
                     (strcat "ss"
                       (
                         (lambda ( j )
                           (vl-some
                             (function
                               (lambda ( x ) (setq j (1+ j))
                                 (if (wcmatch (strcase (cdr (assoc 8 (entget e)))) (strcase x))
                                   (itoa j)
                                 )
                               )
                             )
                             l
                           )
                         )
                         0
                       )
                     )
                   )
                 )
               )
             )
             ( (set sym (ssadd)) )
           )
         )
       )
     )
     (LM:str->lst (cdar l) ",")
   )
 )
)

Link to comment
Share on other sites

???

 

...
 (if (setq ss (ssget '((8 . "[color=red]*[/color]510[color=red]*[color=black],[/color]*[color=black]520[/color]*[/color]"))))
 ...

Link to comment
Share on other sites

You should do some reading on the wcmatch function. It will give you the information you need for ssget selection filtering.

Link to comment
Share on other sites

feel like a rite plonker now, *510* works! cant belive thats all i needed to do for gods sake.

thanks guys

The wonders of wild-cards8)! Only once you start using them you start noticing the shortcomings of ACad's wcmatch function:o. Then you start looking at using regular expressions - but that's a whole different ball-game! :shock:
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...