Results 1 to 5 of 5

Thread: Layer Toggle Buttons

  1. #1
    Member
    Join Date
    2015-09
    Posts
    7
    Login to Give a bone
    0

    Default Layer Toggle Buttons

    I have some buttons that toggle specific layers freeze/thaw, and also toggle specific locked xref layers freeze/thaw. See below.

    Layer
    ^C^C(if (= (cdr (assoc 70 (tblsearch "LAYER" "M_HWR_DIM"))) 1)(command "-layer" "T" "M_HWR_DIM" "")(command "-layer" "F" "M_HWR_DIM" ""))

    Locked Xref Layer
    ^C^C(if (= (cdr (assoc 70 (tblsearch "LAYER" "-XREF_GRID"))) 5)(command "-layer" "T" "-XREF_GRID" "")(command "-layer" "F" "-XREF_GRID" ""))

    My guys want some easy buttons that will do a range of layers. Such as you see in the first macro, the layer is M_HWR_DIM. This works great with a single layer, but if I use a wild card character it will freeze all the correct layers, but will not toggle back to thaw. My layer range would look something like this: M_*dim or just M*dim.

    Any ideas how to get tblsearch to catch the wild cards? I want to freeze/thaw all M_*DIM layers.

  2. #2
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Layer Toggle Buttons

    Just to get this out of the way, you probably should have posted this into one of the Customization forums (maybe AutoLisp).
    Well, the answer is that tblsearch does not use wildcards. It would be nice, but unfortunately it doesn't. You'll have to create a defun of your own which takes a wildcard string then compares it to all the layers in the table using wcmatch then call this function from your button macros, e.g.:
    Code:
    ;; Find all layers matching a wildcard string
    (defun checkLayer (str / lay lst)
      (setq    lst nil                ;Initialize the list to be returned to empty
        lay (tblnext "LAYER" t)        ;Get the 1st layer in the layers table
      ) ;_ end of setq
      ;;  Step through the layers table untill reaching the end
      (while lay
        ;; Check if layername matches with str
        (if    (wcmatch
          (cdr (assoc 2 lay))        ;Get layer name
          str
        ) ;_ end of wcmatch
          (setq lst (cons (cdr (assoc 2 lay)) lst)) ;Add layername to list
        ) ;_ end of if
        (setq lay (tblnext "LAYER"))    ;Get next layer
      ) ;_ end of while
      lst                    ;Return the list of matching layers
    ) ;_ end of defun
    This will return a list containing all the layer names matching the wildcard string, or nil of none are found to match.

  3. #3
    Certifiable AUGI Addict robert.1.hall72202's Avatar
    Join Date
    2004-07
    Location
    Detroit Michigan
    Posts
    2,508
    Login to Give a bone
    0

    Default Re: Layer Toggle Buttons

    I have seen something that uses turns off the layer of a selected
    object. Cannot remember if it is part of autocad or a custom routine.
    Would that help?

    Anyone know of it?

  4. #4
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Layer Toggle Buttons

    Quote Originally Posted by Robert.Hall View Post
    I have seen something that uses turns off the layer of a selected
    object. Cannot remember if it is part of autocad or a custom routine.
    Would that help?

    Anyone know of it?
    Yes it's called Layer Freeze (LAYFRZ) or Layer Off (LAYOFF).

    It used to be part of Express Tools. Now it's part of Acad.

  5. #5
    All AUGI, all the time
    Join Date
    2000-12
    Location
    Blue Springs, MO
    Posts
    658
    Login to Give a bone
    0

    Default Re: Layer Toggle Buttons

    Quote Originally Posted by irneb View Post
    Yes it's called Layer Freeze (LAYFRZ) or Layer Off (LAYOFF).

    It used to be part of Express Tools. Now it's part of Acad.
    They are in the "Layers II" toolbar along with a few others that come in pretty handy.

Similar Threads

  1. 2015: Creating "Toggle" Buttons
    By jgeorge425201 in forum Revit - API
    Replies: 2
    Last Post: 2015-04-17, 02:21 PM
  2. 2015: Toggle Buttons on Quick Access Toolbar?
    By jgeorge425201 in forum Revit Architecture - General
    Replies: 0
    Last Post: 2015-03-23, 07:58 PM
  3. Toggle visibility of layer by layer name
    By mikko.sallinen in forum AutoLISP
    Replies: 3
    Last Post: 2010-04-27, 02:04 AM
  4. Osnap toggle buttons
    By MikeM4OSU in forum AutoCAD General
    Replies: 7
    Last Post: 2005-08-04, 02:35 PM
  5. Toggle Layer ON/OFF
    By madcadder in forum AutoLISP
    Replies: 10
    Last Post: 2005-04-20, 02:36 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
  •