See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Special Layer Freeze LISP Routine

  1. #1
    Member dbanker's Avatar
    Join Date
    2002-12
    Location
    Mushroom Capital of the World
    Posts
    47
    Login to Give a bone
    0

    Question Special Layer Freeze LISP Routine

    Would someone be willing to create a LISP routine for me?
    Here's what I need: I need a layer freeze routine that will detect if the selected object is on the current layer, to make layer 0 current and continue to then freeze that layer.

    Possible? I think so, i just don't know enough about LISP to do this.

    Thanks much!!!

  2. #2
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,505
    Login to Give a bone
    0

    Default Re: Special Layer Freeze LISP Routine

    Quote Originally Posted by dbanker View Post
    Would someone be willing to create a LISP routine for me?
    Here's what I need: I need a layer freeze routine that will detect if the selected object is on the current layer, to make layer 0 current and continue to then freeze that layer.

    Possible? I think so, i just don't know enough about LISP to do this.

    Thanks much!!!
    Sounds very possible.
    Maybe you can explain a little more, are you looking to freeze a particular layer or just select an object and freeze the layer it's on?

    Or something else?

  3. #3
    Login to Give a bone
    1

    Default Re: Special Layer Freeze LISP Routine

    Are you looking for something like this?

    Code:
    (defun c:LFR (/ CLayer$ EntList@ EntName^ Layer$)
      (setq CLayer$ (getvar "CLAYER"))
      (princ "\nSelect object on layer to freeze")
      (if (setq EntName^ (car (entsel)))
        (progn
          (setq EntList@ (entget EntName^))
          (setq Layer$ (cdr (assoc 8 EntList@)))
          (if (and (= Layer$ CLayer$)(/= Layer$ "0"))
            (command ".LAYER" "T" "0" "U" "0" "ON" "0" "S" "0" "")
          );if
          (if (= Layer$ "0")
            (princ "\nCannot freeze layer 0.")
            (command ".LAYER" "F" Layer$ "")
          );if
        );progn
      );if
      (princ)
    );defun c:LFR

  4. #4
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,505
    Login to Give a bone
    0

    Default Re: Special Layer Freeze LISP Routine

    Quote Originally Posted by Terry Cadd View Post
    Are you looking for something like this?

    Code:
    (defun c:LFR (/ CLayer$ EntList@ EntName^ Layer$)
      (setq CLayer$ (getvar "CLAYER"))
      (princ "\nSelect object on layer to freeze")
      (if (setq EntName^ (car (entsel)))
        (progn
          (setq EntList@ (entget EntName^))
          (setq Layer$ (cdr (assoc 8 EntList@)))
          (if (and (= Layer$ CLayer$)(/= Layer$ "0"))
            (command ".LAYER" "T" "0" "U" "0" "ON" "0" "S" "0" "")
          );if
          (if (= Layer$ "0")
            (princ "\nCannot freeze layer 0.")
            (command ".LAYER" "F" Layer$ "")
          );if
        );progn
      );if
      (princ)
    );defun c:LFR
    Nice Terry! I think that's exactly what the OP is looking for.
    I was trying to scab something together, but couldn't make it NOT go to layer zero if it wasn't on the current layer.

  5. #5
    Member dbanker's Avatar
    Join Date
    2002-12
    Location
    Mushroom Capital of the World
    Posts
    47
    Login to Give a bone
    0

    Default Re: Special Layer Freeze LISP Routine

    I will try it and let you know. THANKS!
    Last edited by dbanker; 2008-04-11 at 04:20 PM.

  6. #6
    Member dbanker's Avatar
    Join Date
    2002-12
    Location
    Mushroom Capital of the World
    Posts
    47
    Login to Give a bone
    0

    Smile Re: Special Layer Freeze LISP Routine

    Quote Originally Posted by Terry Cadd View Post
    Are you looking for something like this?

    Code:
    (defun c:LFR (/ CLayer$ EntList@ EntName^ Layer$)
      (setq CLayer$ (getvar "CLAYER"))
      (princ "\nSelect object on layer to freeze")
      (if (setq EntName^ (car (entsel)))
        (progn
          (setq EntList@ (entget EntName^))
          (setq Layer$ (cdr (assoc 8 EntList@)))
          (if (and (= Layer$ CLayer$)(/= Layer$ "0"))
            (command ".LAYER" "T" "0" "U" "0" "ON" "0" "S" "0" "")
          );if
          (if (= Layer$ "0")
            (princ "\nCannot freeze layer 0.")
            (command ".LAYER" "F" Layer$ "")
          );if
        );progn
      );if
      (princ)
    );defun c:LFR
    That work's beautifully! Can i give you credit for it or is it someone elses?

    Again Thanks!

  7. #7
    Login to Give a bone
    1

    Default Re: Special Layer Freeze LISP Routine

    Thanks Doug! It's a slight modification to the one I have in my tool box. However, I like your version better.

    Another version would be if the object selected was the current layer to have the user select an object on a layer to set current before freezing the layer. Here's the code for that.

    Code:
    (defun c:LF (/ CLayer$ EntList@ EntName^ Layer$ Loop NewLayer$)
      (setq CLayer$ (getvar "CLAYER"))
      (princ "\nSelect object on layer to freeze")
      (if (setq EntName^ (car (entsel)))
        (progn
          (setq EntList@ (entget EntName^))
          (setq Layer$ (cdr (assoc 8 EntList@)))
          (if (= Layer$ CLayer$)
            (progn
              (princ "\nThat object is on the current layer.")
              (setq Loop t)
              (while Loop
                (princ "\nSelect object on layer to set current")
                (if (setq EntName^ (car (entsel)))
                  (progn
                    (setq EntList@ (entget EntName^))
                    (setq NewLayer$ (cdr (assoc 8 EntList@)))
                    (if (/= NewLayer$ Layer$)
                      (progn
                        (setvar "CLAYER" NewLayer$)
                        (command ".LAYER" "F" Layer$ "")
                        (setq Loop nil)
                      );progn
                      (princ "\nThat object is also on the current layer.")
                    );if
                  );progn
                  (setq Loop nil)
                );if
              );while
            );progn
            (command ".LAYER" "F" Layer$ "")
          );if
        );progn
      );if
      (princ)
    );defun c:LF

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

    Default Re: Special Layer Freeze LISP Routine

    And if you use (nentsel instead of (entsel then you can obtain nested entities so it works the same way as the LAYFRZ command. Enabling you to freeze layers contained in XRefs / Blocks by picking the nested entities.

    And then the only portion to change in order to make this work exactly the same as LAYFRZ would be to check if the user's inside a floating viewport & then only freeze as a viewport override instead of freezing throughout the DWG.

  9. #9
    Member
    Join Date
    2015-10
    Posts
    2
    Login to Give a bone
    0

    Default Re: Special Layer Freeze LISP Routine

    Can this possibly be modified to make layer '0' current and freeze ALL other layers?

  10. #10
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,505
    Login to Give a bone
    0

    Default Re: Special Layer Freeze LISP Routine

    Quote Originally Posted by yoong710906 View Post
    Can this possibly be modified to make layer '0' current and freeze ALL other layers?
    If that is all you want to do.. here is a simple lisp that puts you on layer zero and freezes all other layers:
    Code:
    (defun c:foo ()
    (setq ce (getvar "cmdecho"))
        (setvar "cmdecho" 0)
    	(command "layer" "s" "0" "")
    	(command "layer" "freeze" "*" "" ) 
    (setvar "cmdecho" ce)
    (princ)
    )
    HTH

Page 1 of 2 12 LastLast

Similar Threads

  1. LISP routine to overwrite layer descriptions...
    By dortega4269 in forum AutoLISP
    Replies: 39
    Last Post: 2014-07-23, 08:04 PM
  2. Layer Color Change LISP Routine
    By guardianfiredesign774457 in forum AutoLISP
    Replies: 19
    Last Post: 2013-08-28, 05:08 AM
  3. Add layer command line to a lisp routine
    By BrianTFC in forum AutoLISP
    Replies: 1
    Last Post: 2012-02-02, 07:47 AM
  4. Layer Freeze/Thaw toggle routine
    By jgardner.79905 in forum AutoLISP
    Replies: 5
    Last Post: 2010-02-01, 09:39 PM
  5. Layer creation lisp routine?
    By boeris9333 in forum AutoLISP
    Replies: 10
    Last Post: 2009-10-05, 11:24 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
  •