Exclude Layers via a Wildcard

Exclude Layers via a Wildcard

David_Prontnicki
Collaborator Collaborator
1,852 Views
6 Replies
Message 1 of 7

Exclude Layers via a Wildcard

David_Prontnicki
Collaborator
Collaborator

Hi everyone,

 

I am trying to figure how to select layers via a wildcard. In the code below I am selecting all the layers in a specific XREF and changing the plotstyle. There are specific layers that I would like to exclude. I have about 10 easement layers and do not want to have to list each layer; they all start with V-EASE, so I would like to say, anything that starts with V-EASE, exclude. The code below with the * does not work, not sure how to do that. 

 

Also If anyone has a better way to do what I am doing overall, I am all ears. 

(defun c:Test5 (/ ActDoc)

(vlax-for Lay 

;;; Get layers from active document    
    (vla-get-Layers

        (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))
        ) ;_ end of setq

    ) ;_ end of vla-get

;;; Plotstyle control for C-BASE 
    (if 
    
        (and (= (vl-string-search "C-BASE|" (vla-get-Name Lay)))

            (not (member (strcase (vla-get-name Lay)) '("C-BASE|V-PROP-SBACK-TEXT" 
        					                            "C-BASE|V-PROP-DEED-TEXT"
        					                            "C-BASE|V-BNDY-TSHP-TEXT"
        					                            "C-BASE|V-ESMT-*"))
            ) ;_ end of not
            
        ) ;_ end of and

    (vla-put-plotstylename Lay "G02060")

    ) ;_ end of if for C-BASE

) ;_ end of vlax-for

(vla-Regen ActDoc acActiveViewport)

(princ)

) ;_ end of defun

 

0 Likes
Accepted solutions (2)
1,853 Views
6 Replies
Replies (6)
Message 2 of 7

cadffm
Consultant
Consultant
Use wcmatch for comparing.

Sebastian

0 Likes
Message 3 of 7

David_Prontnicki
Collaborator
Collaborator
Thank you, I have played with the wcmatch but have been unable to figure out the format for listing multiple items. How do you do that? Separated by a comma doesn’t work nor does just listing.
0 Likes
Message 4 of 7

cadffm
Consultant
Consultant
Accepted solution
Comma works, i am pretty sure.
And for multiple conditions you can use COND too.

(wcmatch (strcase LAYER) "LA1,MYLAY,ALL*")

Sebastian

0 Likes
Message 5 of 7

doaiena
Collaborator
Collaborator
Accepted solution

Try this:

(defun c:test (/ actDoc layLst)

  (setq layLst ("C-BASE|V-PROP-SBACK-TEXT" "C-BASE|V-PROP-DEED-TEXT" "C-BASE|V-BNDY-TSHP-TEXT" "C-BASE|V-ESMT-*"))
  (vlax-for lay	(vla-get-Layers (setq actDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))))

    (if	(and (= (vl-string-search "C-BASE|" (vla-get-Name lay)))
	     (not (member (strcase (vla-get-name lay)) layLst))
	     (not (wcmatch (strcase (vla-get-name lay)) "*V-EASE*"))
	)
      (vla-put-plotstylename lay "G02060")
    )
  )
  (vla-Regen ActDoc acActiveViewport)
  (princ)
) ;defun
Message 6 of 7

David_Prontnicki
Collaborator
Collaborator
Ooohhh, I had a space after each comma. That might have been the issue. I will give this a try shortly and let you know. Thank you very much.
0 Likes
Message 7 of 7

David_Prontnicki
Collaborator
Collaborator

Hi I tried your idea, I had to add a ' to the beginning of the list to make it 

(setq layLst '("C-BASE|V-PROP-SBA... 
 
It runs but does not exclude the V-ESMT layers. They are still changing. Any Suggestions?
 
****** Nevermind ******* It was a spelling mistake. 🙂
0 Likes