Jump to content

Help on Lisp for turn off layer exempt xref and variable


Kokhanetz

Recommended Posts

Hi Guys,

 

im trying and bugging all day long and i think im not seeing:

 

(defun c:xra ( / ss)
	(setq ss (ssget "_X" (list (cons 0 "LWPOLYLINE")(cons 8 "~*ET_LS*"))))
	*
	(princ "\nDone")
(princ) 	
)

 

setq works because i want to turn off all layers except layer with *ET_LS* 

but command line: 

 

(command "-LAYER" "OFF" ss "")

 doesnt seem to work

 

another thing i want to exclude is all xrefs:

(setq xref (cdr(assoc 2 (entget(car(entsel))))))

it should be smoething with that,

 

but im really struggeling getting it all to work in 1 command. I thought it was a easy script...

 

Hope you guys can help me again with the whole code.

 

Thnx in advance..

Greetz

Link to comment
Share on other sites

--- Sunday so CAD is off and not checked this but --

 

Your layer command (command "-layer" "off" ss "")

(command - yes, makes sense, 

"-layer" - yes got to say what command to use

"off" - yes makes sense, tell the layer to be off

ss - the layer name to turn off - which I think you are using a selection set reference (a list of objects in the drawing) and not a layer name?

"" - yes makes sense, end the command

 

 

Though with CAD off, google still works and this (https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/turning-off-layers-in-autolisp/td-p/6339611) from Kent Cooper might help - turn off all layers however you want and then turn on any with *ET_LS using the WCMatch, and removing the question

Link to comment
Share on other sites

(while (setq l (tblnext "LAYER" (not l)))
    (or (wcmatch (setq n (cdr (assoc 2 l))) "*ET_LS*,*|*")
         (or (minusp (setq v (cdr (assoc 62 (setq e (entget (tblobjname "LAYER" n)))))))
             (entmod (append e (list (cons 62 (- v)))))
             )
         )
    )

 

  • Like 1
Link to comment
Share on other sites

Another

(defun c:loffs ( / ss)
(setq ss (ssget "_X" (list (cons 0 "LWPOLYLINE")(cons 8 "~*ET_LS*"))))
(repeat (setq x (sslength ss))
    (command "-layer" "off" (cdr (assoc 8 (entget (ssname ss (setq x (1- x)))))) "")
)
(princ)
)

 

Edited by BIGAL
Link to comment
Share on other sites

 

@Tharwat, the code worked,:

10 hours ago, Tharwat said:
(while (setq l (tblnext "LAYER" (not l)))
    (or (wcmatch (setq n (cdr (assoc 2 l))) "*ET_LS*,*|*")
         (or (minusp (setq v (cdr (assoc 62 (setq e (entget (tblobjname "LAYER" n)))))))
             (entmod (append e (list (cons 62 (- v)))))
             )
         )
    )

 

@BIGAL ,

I noticed on your code it does work, but it keeps on loading in drawing.

I need to do ESC to finish the command.

6 hours ago, BIGAL said:
(setq ss (ssget "_X" (list (cons 0 "LWPOLYLINE")(cons 8 "~*ET_LS*"))))
(repeat (setq x (sslength ss))
    (command "-layer" "off" (cdr (assoc 8 (entget (ssname ss (setq x (1- x)))))) "")
)

 

Thnx again both for the help. Gonna learn from it.

Edited by Kokhanetz
Link to comment
Share on other sites

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