Results 1 to 2 of 2

Thread: Step through layers - if *match, then..

  1. #1
    Member
    Join Date
    2019-05
    Posts
    15
    Login to Give a bone
    0

    Default Step through layers - if *match, then..

    Hi.
    I'm trying to write a bit of code that steps through my layers, and if there's a match of "*EXIST", it runs the function I've written up. Else, moves on to the next.

    Code:
    (defun c:MICKY (/ layOld layNew ss)
    
    (setq layOld (getvar "clayer"))
    (setq layNew (strcat layOld "-OFF"))
    
    ;STEP THROUGH LAYERS
    ;> IF MATCH "*EXIST" THEN...
    
    (setq ss (ssget "x" (list (cons 8 (getvar "CLAYER")))))
    (command "-COPYTOLAYER" ss "" layNew "y" "0,0,0" "")
    
    ;>ELSE NEXT LAYER
    
    )
    Pretty simple function i think but I have doo-doo brain so would really appreciate any sort of help or guidance.

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: Step through layers - if *match, then..

    So your looking for any layer that has EXIST in the name ?

    Code:
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (vlax-for layer (vla-get-layers doc)
    (if (= (wcmatch  (vla-get-name layer) "*EXIST") T)
    (alert "match found")
    (alert "not found")
    )
    )

Similar Threads

  1. Looking for step by step guide for Civil 3D 2006 or 2007
    By sergio_garces_salgado in forum AutoCAD Civil 3D - General
    Replies: 6
    Last Post: 2006-08-23, 06:12 PM
  2. Step by step guide - create two set-ups
    By VBOYAJI in forum AutoCAD CUI Menus
    Replies: 2
    Last Post: 2006-03-20, 11:14 PM
  3. Step-by-Step explanation window does not appear any more
    By dbrach in forum AutoCAD LT - General
    Replies: 2
    Last Post: 2005-12-04, 11:37 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
  •