Layer filter wildcards (how to have multiple)

Discussion in 'AutoCAD' started by Jake Pitcher, Jan 27, 2005.

  1. Jake Pitcher

    Jake Pitcher Guest

    Hi everyone. I am trying to create a layer filter using the ~ (tilde), but
    need it for 2 exclusions in one filter. My mechanical layers are set up in
    3 categories, one each for "new work", "existing work" and "demolition
    work", for example: M-HVAC-DSUP (new work), M-HVAC-DSUP-X (existing work)
    and M-HVAC-DSUP-D (demolition work). I have layer filters "MECH-EXST" for
    showing only existing work layers and "MECH-DEMO" for showing only
    demolition work layers. I would like one that shows only new work layers.
    Currently I have ~*-X in my "MECH-NEW" layer filter, but it shows all new
    work layers and demolition layers (excluding all existing layers). I have
    looked through help under several different search subjects trying to find a
    way to seperate wildcard criteria in the Named Layer Filters dialog box, but
    cannot find anything. I've tried doing ~*-X;~*-D as well as ~*-X,~*-D
    (using a semicolon in the first attempt and a comma in the second) to no
    avail.

    I've already tried to get everyone to agree to just add a -N to the end of
    the new work layers, but nobody wants to change. So I'm left with trying
    these wildcards.

    Any help would be appreciated greatly, thank you in advance.

    Jake Pitcher
    AutoCAD 2002
    Windows XP Pro
     
    Jake Pitcher, Jan 27, 2005
    #1
  2. Jake Pitcher

    T.Willey Guest

    If the last two characters of the layers you want off are always "-X" "-D", then it should be to hard in lisp.

    (defun c:NewLayerFilter (/ ActDoc clay LayCol tmpLayName)

    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vla-StartUndoMark ActDoc)
    (setq clay (getvar "clayer"))
    (if (or
    (= (strcase (substr clay (1- (strlen clay)))) "-D")
    (= (strcase (substr clay (1- (strlen clay)))) "-X")
    )
    (setvar "clayer" "0")
    )
    (setq LayCol (vla-get-Layers ActDoc))
    (vlax-for item LayCol
    (setq tmpLayName (vla-get-Name item))
    (if (or
    (= (strcase (substr tmpLayName (1- (strlen tmpLayName)))) "-D")
    (= (strcase (substr tmpLayName (1- (strlen tmpLayName)))) "-X")
    )
    (vla-put-LayerOn item :vlax-false)
    (vla-put-LayerOn item :vlax-true)
    )
    )
    (vla-EndUndoMark ActDoc)
    (princ)
    )

    See if that works.
    Tim
    ps. Written on the fly.
     
    T.Willey, Jan 27, 2005
    #2
  3. Jake Pitcher

    Jake Pitcher Guest

    Tim, I loaded that lisp that you wrote, but it gave back an error, which was
    ; error: bad argument value: positive 0
    Any ideas what it might be?

    Jake
     
    Jake Pitcher, Jan 27, 2005
    #3
  4. Jake Pitcher

    T.Willey Guest

    Try this one. The problem was when a layers name was only one character.

    Tim

    (defun c:NewLayerFilter (/ ActDoc clay LayCol tmpLayName)

    (vl-load-com)
    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vla-StartUndoMark ActDoc)
    (setq clay (getvar "clayer"))
    (if
    (and (> (strlen clay) 2)
    (or
    (= (strcase (substr clay (1- (strlen clay)))) "-D")
    (= (strcase (substr clay (1- (strlen clay)))) "-X")
    )
    )
    (setvar "clayer" "0")
    )
    (setq LayCol (vla-get-Layers ActDoc))
    (vlax-for item LayCol
    (setq tmpLayName (vla-get-Name item))
    (if
    (and (> (strlen clay) 2)
    (or
    (= (strcase (substr clay (1- (strlen clay)))) "-D")
    (= (strcase (substr clay (1- (strlen clay)))) "-X")
    )
    )
    (vla-put-LayerOn item :vlax-false)
    (vla-put-LayerOn item :vlax-true)
    )
    )
    (vla-EndUndoMark ActDoc)
    (princ)
    )
     
    T.Willey, Jan 27, 2005
    #4
  5. Jake Pitcher

    James Allen Guest

    Does ~*-[XD] do what you want?
     
    James Allen, Jan 27, 2005
    #5
  6. Jake Pitcher

    Jake Pitcher Guest

    Yes, that worked just fine.... I also figured out another way about an hour
    before reading your message, and that was ~*-?

    Thanks for the help guys, I appreciate it.

    Jake Pitcher


     
    Jake Pitcher, Jan 28, 2005
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.