Dhammike Posted May 4, 2020 Posted May 4, 2020 (progn (command "_.layer" "on" "TEXT-PN" "Thaw" "TEXT-PN" "unlock" "TEXT-PN" "") (command "_.layer" "off" "POINT-FS" "" "" "" "" "") (command "_.layer" "off" "POINT-SN" "" "" "" "" "") (command "_.layer" "off" "POINT-TN" "" "" "" "" "") (command "_.layer" "off" "POINT-TP" "" "" "" "" "") (command "_.layer" "off" "TEXT-SC" "" "" "" "" "") );progn In my programme above layer commands are include. while i am running above tool layer running display as below. Command: _.layer Current layer: "HATCHS" Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: NEW Enter name list for new layer(s): HATCHS Layer "HATCHS" already exists. Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: _color New color [Truecolor/COlorbook] : CYAN Enter name list of layer(s) for color 4 (cyan) <HATCHS>: HATCHS Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: ON is there any possibility to run the tool silenlty, without displaying above lines . Thanks in advance. Quote
Jonathan Handojo Posted May 4, 2020 Posted May 4, 2020 (edited) Look at the CMDECHO variable that you can set. Below is an example (defun yourfunction ( / *error* cmd) (defun *error* (msg) (setvar 'cmdecho cmd) (princ (strcat "\nError: " msg))) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (progn (command "_.layer" "on" "TEXT-PN" "Thaw" "TEXT-PN" "unlock" "TEXT-PN" "") (command "_.layer" "off" "POINT-FS" "" "" "" "" "") (command "_.layer" "off" "POINT-SN" "" "" "" "" "") (command "_.layer" "off" "POINT-TN" "" "" "" "" "") (command "_.layer" "off" "POINT-TP" "" "" "" "" "") (command "_.layer" "off" "TEXT-SC" "" "" "" "" "") );progn (setvar 'cmdecho cmd) ) I personally try to avoid the (command) where possible though because if I were dealing with hundreds, if not thousands, of layers, then it will consume a lot of time. Alternatively, I would do this to turn off a layer: (defun c:offlayer ( / cur layobj off) (foreach x '("POINT-FS" "POINT-FS" "POINT-SN" "POINT-TN" "POINT-TP") (setq layobj (tblobjname "layer" x) cur (assoc 62 (entget layobj))) (if (> (setq off (cdr cur)) 0) (entmod (subst (cons 62 (- off)) cur (entget layobj))) ) ) (princ) ) I've used something similar to lock thousands of layers (at least 2k) by selecting object whose layers are to be locked, and it worked surprisingly fast. Freezing is a different story though. Edited May 4, 2020 by Jonathan Handojo Quote
Dhammike Posted May 4, 2020 Author Posted May 4, 2020 1 hour ago, Jonathan Handojo said: Look at the CMDECHO variable that you can set. Below is an example (defun yourfunction ( / *error* cmd) (defun *error* (msg) (setvar 'cmdecho cmd) (princ (strcat "\nError: " msg))) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (progn (command "_.layer" "on" "TEXT-PN" "Thaw" "TEXT-PN" "unlock" "TEXT-PN" "") (command "_.layer" "off" "POINT-FS" "" "" "" "" "") (command "_.layer" "off" "POINT-SN" "" "" "" "" "") (command "_.layer" "off" "POINT-TN" "" "" "" "" "") (command "_.layer" "off" "POINT-TP" "" "" "" "" "") (command "_.layer" "off" "TEXT-SC" "" "" "" "" "") );progn (setvar 'cmdecho cmd) ) I personally try to avoid the (command) where possible though because if I were dealing with hundreds, if not thousands, of layers, then it will consume a lot of time. Alternatively, I would do this to turn off a layer: (defun c:offlayer ( / cur layobj off) (foreach x '("POINT-FS" "POINT-FS" "POINT-SN" "POINT-TN" "POINT-TP") (setq layobj (tblobjname "layer" x) cur (assoc 62 (entget layobj))) (if (> (setq off (cdr cur)) 0) (entmod (subst (cons 62 (- off)) cur (entget layobj))) ) ) (princ) ) I've used something similar to lock thousands of layers (at least 2k) by selecting object whose layers are to be locked, and it worked surprisingly fast. Freezing is a different story though. Thankyou very much. both tools are working. Quote
BIGAL Posted May 5, 2020 Posted May 5, 2020 (edited) Simpler off supports multiple "POINT-FS,POINT-FS,POINT-SN,POINT-TN,POINT-TP" or if only point layers "POINT*" Edited May 5, 2020 by BIGAL Quote
Dhammike Posted May 5, 2020 Author Posted May 5, 2020 1 hour ago, BIGAL said: Simpler off supports multiple "POINT-FS,POINT-FS,POINT-SN,POINT-TN,POINT-TP" or if only point layers "POINT*" Thanks for comment. Do you meen use "POINT-FS,POINT-FS,POINT-SN,POINT-TN,POINT-TP" within foreach function. Quote
Jonathan Handojo Posted May 5, 2020 Posted May 5, 2020 1 hour ago, Dhammike said: Thanks for comment. Do you meen use "POINT-FS,POINT-FS,POINT-SN,POINT-TN,POINT-TP" within foreach function. Nah, he meant if your layer starts with POINT (wcmatch txt "POINT*"), so instead of making a list, scan all the layers you got and only off those layers matching the criteria. Quote
Dhammike Posted May 5, 2020 Author Posted May 5, 2020 1 hour ago, Jonathan Handojo said: Nah, he meant if your layer starts with POINT (wcmatch txt "POINT*"), so instead of making a list, scan all the layers you got and only off those layers matching the criteria. Thank you, Jonathan. I got it. But sometimes we use ZWCAD instead of AUTOCAD, wcmatch doesn't work in ZWCAD. (defun c:offlayer ( / cur layobj off) (foreach x '("POINT-FS" "POINT-FS" "POINT-SN" "POINT-TN" "POINT-TP") (setq layobj (tblobjname "layer" x) cur (assoc 62 (entget layobj))) (if (> (setq off (cdr cur)) 0) (entmod (subst (cons 62 (- off)) cur (entget layobj))) ) ) (princ) ) Your above program does not work in ZWCAD as well. Anyway Thanks lot for both you and Bigal again. I hope you two can solve my problem. 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.