Tripledot 发表于 2022-7-5 17:32:25

layer created & sorted base on

Description of lisp
How to make lisp include entities inside nested blocks? 

; CBLAYR.LSPChange entity color to BYLAYER.;; This program sorts entities by their color, and places all entities with; the same color on a layer whose name is the color number (e.g., entities; with the color # 3 will be placed on a layer named "3").;; The entity color of all entities are changed to "BYLAYER", and the layer; inherits the color of the entities placed on it.;; Essentially, this program was written to eliminate entities with explicit; color properties, in preperation for exporting via DXF to a post-processor; that does not honor color-by-entity.   Use at your own risk.(defun C:CBYLAYER ( / ss i hi clayer)   (initget 7)   (setq maxcolor (getint "\nHighest color number: "))   (setq i 0)   (princ "\nConverting entity colors from by-entity to by-layer...")   (setq hi (getvar "highlight"))   (setq clayer (getvar "clayer"))   (setvar "highlight" 0)   (setvar "cmdecho" 0)   (command ".layer")   (repeat maxcolor (command "make" (itoa (setq i (1+ i))) "c" i ""))   (command "")   (setq i 0)   (repeat maxcolor      (if (setq ss (ssget "x" (list (cons 62 (setq i (1+ i))))))            (command ".chprop" ss "" "la" (itoa i) "c" "bylayer" "")))   (setvar "highlight" hi)   (command ".layer" "s" clayer "")   (princ))

rlx 发表于 2022-7-5 18:31:51

Hi Tripledot,
 
 
Study this link http://www.cadtutor.net/forum/showthread.php?19161-lisp-for-changing-all-objects-in-a-block-to-layer-quot-0-quot
 
 
You can also find some examples on Lee's site on how to acces subentities in a block , some examples are easier to understand than others (for a beginner?) but all are elegantly written.
 
 
Gr. Rlx

Tripledot 发表于 2022-7-5 18:44:58

Found answer here
 
http://www.cadtutor.net/forum/showthread.php?533-Lisp-colour-change-for-all-layers-and-blocks&p=531712&viewfull=1#post531712
页: [1]
查看完整版本: layer created & sorted base on