Hi, how can I browse through layers with tblnext but jump over the xref-dependent ones?
(setq layerinturn (cdr (cadr (tblnext "layer")))) gives me all of them.
|
Hi, how can I browse through layers with tblnext but jump over the xref-dependent ones?
(setq layerinturn (cdr (cadr (tblnext "layer")))) gives me all of them.
Perhaps:
Code:(defun NonXrefLayers ( / def lst ) (while (setq def (tblnext "LAYER" (null def))) (if (not (wcmatch (cdr (assoc 2 def)) "*|*")) (setq lst (cons (cdr (assoc 2 def)) lst)) ) ) (acad_strlsort lst) )
Thank You, I got the list of layers ok!
What I'm trying is to give different colours to all layers. Something is still wrong, because the following try gives me "error: no function definition: NULL".
Code:(defun c:cbl (/ null def Ent a layerinturn) ;Trying to color all layers with different colours (setvar "cmdecho" 0) (command "_.undo" "begin") (command "-layer" "on" "*" "t" "*" "") (command "change" "all" "" "p" "C" "bylayer" "lw" "bylayer" "") (while (setq def (tblnext "LAYER" (null def))) (if (not (wcmatch (cdr (assoc 2 def)) "*|*")) (setq lst (cons (cdr (assoc 2 def)) lst)) ) ) (acad_strlsort lst) (setq a 1) (repeat (sslength lst) (setq layerinturn (ssname lst a)) (command "_.-layer" "c" a layerinturn "") (setq a (+ 1 a)) ) (command "_.undo" "end") (setvar "cmdecho" 1) (princ) )
Last edited by tuomo.jarvinen; 2011-10-26 at 12:31 PM.
Your error is due to you localising the protected 'null' function in the defun expression, also 'lst' is not a SelectionSet, so sslength and ssname will error.
Are you using a code editor with syntax highlighting to write your code?
Consider this code:
Code:(defun c:laycol ( / col def lst name ) (setq col 0) (while (setq def (tblnext "LAYER" (null def))) (if (not (wcmatch (setq name (cdr (assoc 2 def))) "*|*")) (progn (setq lst (entget (tblobjname "LAYER" name))) (entmod (subst (cons 62 (setq col (1+ col))) (assoc 62 lst) lst)) ) ) ) (princ) )
Oops! You solved it for me already... thanks!! Looks so easy when you can!
- I'm only using notepad for editing.
How do I rate this issue solved?
Last edited by tuomo.jarvinen; 2011-10-26 at 01:35 PM.