Jest Posted March 23, 2021 Posted March 23, 2021 I need a lisp routine to freeze currently selected objects on multi different layers at once. Instead to run LAYFRZ command and pick them one by one, I would like to select them first (like window selection) and then run single command to freeze them and so theirs layers all at once. Any Ideas? Quote
Tharwat Posted March 23, 2021 Posted March 23, 2021 (defun c:Test (/ i s c e y l b k) ;; Tharwat - Date: 24.Mar.2021 ;; ;; Freeze layers of selected objects ;; ;; NOTE: excludes if any of the layers is current. ;; (and (princ "\nSelect objects to Freeze their layers : ") (setq c (getvar 'CLAYER) i -1 s (ssget '((0 . "~VIEWPORT"))) ) (while (setq i (1+ i) e (ssname s i) ) (or (member (setq y (cdr (assoc 8 (entget e)))) l) (= c y) (and (setq l (cons y l) b (entget (tblobjname "LAYER" y)) k (assoc 70 b) ) (entmod (subst (cons 70 (1+ (cdr k))) k b)) ) ) ) ) (princ) ) 2 Quote
Jest Posted March 24, 2021 Author Posted March 24, 2021 Perfect...exactly what I need. Thank you! Quote
Jest Posted March 26, 2021 Author Posted March 26, 2021 By the way, could you know the answer to my old post? Quote
mikitari Posted May 13 Posted May 13 (edited) On 3/23/2021 at 9:56 PM, Tharwat said: (defun c:Test (/ i s c e y l b k) ;; Tharwat - Date: 24.Mar.2021 ;; ;; Freeze layers of selected objects ;; ;; NOTE: excludes if any of the layers is current. ;; (and (princ "\nSelect objects to Freeze their layers : ") (setq c (getvar 'CLAYER) i -1 s (ssget '((0 . "~VIEWPORT"))) ) (while (setq i (1+ i) e (ssname s i) ) (or (member (setq y (cdr (assoc 8 (entget e)))) l) (= c y) (and (setq l (cons y l) b (entget (tblobjname "LAYER" y)) k (assoc 70 b) ) (entmod (subst (cons 70 (1+ (cdr k))) k b)) ) ) ) ) (princ) ) It is brilliant, thank you Tharwat! @Tharwat I know this one is 4 years old, but pure gold! Could this lisp perform in viewport space a Viewport Freeze instead of regular Freeze? Best regards!! Edited May 13 by mikitari Quote
mikitari Posted May 20 Posted May 20 (edited) Hello, I asked ChatGPT for help, please excuse Tharwat, apparently it nailed it at first shot. (defun c:TestVPFreeze (/ i s c e y l) ;; Tharwat - Date: 24.Mar.2021 ;; ;; Freeze layers of selected objects ;; ;; ChatGPT - Modified for VP Freeze - 20.May.2025 ;; ;; VP Freeze layers of selected objects in current layout viewport ;; NOTE: excludes if any of the layers is current. (and (princ "\nSelect objects to VP Freeze their layers in the current viewport: ") (setq c (getvar 'CLAYER) i -1 s (ssget '((0 . "~VIEWPORT"))) ) (while (setq i (1+ i) e (ssname s i)) (setq y (cdr (assoc 8 (entget e)))) ; Get layer name (if (and (/= c y) (not (member y l))) ; Not current and not already processed (progn (setq l (cons y l)) ; Track processed layers ;; Use VPLAYER command to freeze in current viewport (command "_.vplayer" "_freeze" y "" "") ) ) ) ) (princ) ) Notes from Chatgpt: This uses (command "_.vplayer" "freeze" ...) for viewport-specific freezing. Ensure the user is inside a layout viewport (i.e., paper space, double-clicked into a viewport). Skips the current layer and avoids freezing the same layer multiple times. Edited May 20 by mikitari Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.