Jump to content

Recommended Posts

Posted
 (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.

 

Posted (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 by Jonathan Handojo
Posted
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. 

Posted (edited)

Simpler off supports multiple "POINT-FS,POINT-FS,POINT-SN,POINT-TN,POINT-TP" or if only point layers "POINT*"

Edited by BIGAL
Posted
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.

Posted
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.

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...