Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Hide All / layer isolate

  1. #1
    Member
    Join Date
    2010-08
    Posts
    7
    Login to Give a bone
    0

    Default Hide All / layer isolate

    I am attempting to write a LISP routine that would turn off all layers except the current layer. There is a command in toolpac that does something really similar, but I have to pick an object and that objects layer is the layer that is left on (command is Layer Isolate LIS c:dstp_layriso and it has a layer restore command as well Layer Restore LR c:layrrest). I use to work at a place that had a command HA to hide all and SH to show all (basically turn on all layers that were on prior to using the HA command).

    My thought was to write a LISP routine using the toolpac command and just adding to it, but I have no clue how to do that. Provided that the LISP routine was based on the LIS command, then the alias for the layer restore command in toolpac could simply be changed to SH.

    Thanks

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: Hide All / layer isolate

    Quote Originally Posted by nick.259007 View Post
    I am attempting to write a LISP routine that would turn off all layers except the current layer.
    I don't quite follow the rest of your post, but the following will do the above.
    Bare bones...it does not reset the expert system variable.

    Code:
    (if (zerop (getvar "expert"))
      (setvar "expert" 1)
    )  
    (vl-cmdf "-layer" "off" "*" "on" (getvar "clayer") "")
    R.K. McSwain | CAD Panacea |

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Hide All / layer isolate

    If I may, RK... You're correct with two small additions:

    Quote Originally Posted by rkmcswain View Post
    Code:
    (vl-cmdf "-layer" "off" "*" "" "on" (getvar "clayer") "")

    Provided the user does not manipulate the layer settings prior to attempting to restore them to their previous state, use this:
    Code:
    (vl-cmdf "._layerp")
    Last edited by RenderMan; 2010-10-04 at 02:18 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: Hide All / layer isolate

    Quote Originally Posted by RenderMan View Post
    If I may, RK... You're correct with two small additions:
    No, actually it was right the first time.
    (vl-load-com) is not required and I'm not sure what makes you think you need that extra return in the command string..

    PHP Code:
    Command: (vl-cmdf "-layer" "off" "*" "on" (getvar "clayer""")
    -
    layer
    Current layer
    :  "Rail Roads"
    Enter an option 
    [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck
    /Unlock/stAte/Description/rEconcile]: off
    Enter name 
    list of layer(sto turn off or <select objects>: * Enter an option 
    [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck
    /Unlock/stAte/Description/rEconcile]: on
    Enter name 
    list of layer(sto turn onRail Roads Enter an option 
    [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck
    /Unlock/stAte/Description/rEconcile]:
    Command
    R.K. McSwain | CAD Panacea |

  5. #5
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Hide All / layer isolate

    Code:
    (command "_.-layer" "_off" (strcat "*,~" (getvar 'clayer)) "" "")

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

    Default Re: Hide All / layer isolate

    Yes of course you can use command instead of vl-cmdf (which may alleviate the vl-load-com issue, whether it's needed or not).

    Although that setvar "Expert" thing needs to be reset back to its old value. Just good practice!

    Or you can simply do as the LayIso does:
    Code:
    (vl-load-com)
    (defun c:LayIsoCur (/ clay layers lay)
      (layerstate-save "_LAYISO_STATE" nil nil)
      (setq clay (getvar "CLAYER")
            layers (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
            )
      (vlax-for lay layers
        (vla-put-LayerOn lay (if (eq clay (vla-get-Name lay)) :vlax-true :vlax-false))
      )
      (princ)
    )
    There's 4 nice things about this:
    1. You don't need worry about the Expert variable's value.
    2. There's nothing extra displayed on the command line.
    3. It can be called transparently using 'LayIsoCur.
    4. Even if the user modified the layer settings in between, the standard LayUnIso command will still restore it back to just before the LayIsoCur command was issued, same as if you've used the standard LayIso command.
    Actually it doesn't work as I expected. The LayUnIso doesn't see it correctly, and LayerP doesn't either Will have to look into this a bit more
    Last edited by irneb; 2010-10-02 at 11:47 PM. Reason: Doesn't work as expected

  7. #7
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Hide All / layer isolate

    Quote Originally Posted by irneb View Post
    Yes of course you can use command instead of vl-cmdf (which may alleviate the vl-load-com issue, whether it's needed or not).

    Although that setvar "Expert" thing needs to be reset back to its old value. Just good practice!
    While I totally agree with you and would use/suggest vla or entmod, simply because it will allow you to run it transparently, you should take another look at my post, it doesn't require changing of the Expert system variable.

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

    Default Re: Hide All / layer isolate

    Quote Originally Posted by alanjt View Post
    While I totally agree with you and would use/suggest vla or entmod, simply because it will allow you to run it transparently, you should take another look at my post, it doesn't require changing of the Expert system variable.
    Sorry, yes, you're correct! Missed that tilde .

    But this is bugging me. I've figured out I need to delete the layer state before saving it (if it already exists). But even then LayUnIso gives the following message:
    Code:
    No layers to restore from LAYISO command.
    It does use the _LAYISO_STATE layer state, since it creates that with LayIso and erases it on LayUnIso. It must set some state variable somewhere as well ... just can't seem to find it.

    And worst of all the LayerP doesn't seem to recognize layer changes from VLA. Which is damned silly!

  9. #9
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Hide All / layer isolate

    Quote Originally Posted by irneb View Post
    Sorry, yes, you're correct! Missed that tilde .

    But this is bugging me. I've figured out I need to delete the layer state before saving it (if it already exists). But even then LayUnIso gives the following message:
    Code:
    No layers to restore from LAYISO command.
    It does use the _LAYISO_STATE layer state, since it creates that with LayIso and erases it on LayUnIso. It must set some state variable somewhere as well ... just can't seem to find it.

    And worst of all the LayerP doesn't seem to recognize layer changes from VLA. Which is damned silly!
    I never knew that about LayUnIso (granted, I never use it - have my own concoction); very odd. I wonder if it would work on versions where LayIso was still a LISP routine.

    LayerP should work fine with using vla/entmod and changing on/off thaw/freeze state of a layer. I use it all the time. Hell, I just checked it and it worked. Odd that it's not working on your end.

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

    Default Re: Hide All / layer isolate

    Very strange. Must've been a bug in my ACad yesterday, today it works fine with LayerP. In any case, I decided to make my own unisolate function:
    Code:
    (vl-load-com)
    (defun c:LayIsoCur (/ clay layers lay)
      (layerstate-delete "_LAYISOCUR_STATE")
      (layerstate-save "_LAYISOCUR_STATE" 1 nil)
      (setq clay (getvar "CLAYER")
            layers (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
            )
      (vlax-for lay layers
        (vla-put-LayerOn lay (if (eq clay (vla-get-Name lay)) :vlax-true :vlax-false))
      )
      (princ)
    )
    
    (defun c:LayUnIsoCur (/)
      (if (layerstate-has "_LAYISOCUR_STATE")
        (progn
          (layerstate-restore "_LAYISOCUR_STATE")
          (layerstate-delete "_LAYISOCUR_STATE")
        )
        (print "There's no layer state to restore.")
      )
      (princ)
    )
    I cannot understand why whomsoever changed the LayIso from the Express Tools in 2006 into the "new" ARXs had to go and place another variable somewhere arbitrary. As you can see it's not an enormous task to check if the layer state exists or not. My guess is it's another green as grass programmer who didn't know what he was doing: Ahhh! I've just come out of a 2 month course on DotNet. I know it all! ... Yeah right! All you know is how to screw up something which is working perfectly as it is!

    Anyhow, looking at my 2006's CD's I got hold of the old AcEtLayr.LSP file. There must've been quite a "huge" change, since it used that old LMAN to store the state into "ACET-LAYISO". Nowhere did it store yet another bloody variable.

Page 1 of 3 123 LastLast

Similar Threads

  1. hide / isolate objects using vb.net
    By El Martino in forum Dot Net API
    Replies: 0
    Last Post: 2012-10-23, 08:16 PM
  2. Groups / Hide Isolate
    By The Monk in forum Revit Architecture - General
    Replies: 0
    Last Post: 2012-01-05, 05:39 PM
  3. isolate/hide surface
    By tlewald in forum Civil 3D Wish List
    Replies: 0
    Last Post: 2006-03-23, 08:25 PM
  4. hide/isolate
    By CCI Design in forum Revit Architecture - Wish List
    Replies: 1
    Last Post: 2004-09-09, 05:10 PM
  5. Hide/Isolate
    By Urban D in forum Revit Architecture - General
    Replies: 2
    Last Post: 2003-11-24, 11:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •