ksperopoulos,
下面是我在Afralisp上找到的代码http://www.afralisp.net/archive/lisp/clay.htm这涉及到将图元颜色属性设置为“bylayer”的主题。还有其他方面,例如线型和块,可以让您更好地了解如何继续。一旦你对这段代码有了想法,我希望剩下的事情会变得更容易。Afralisp有一种很好的方法,可以用简单的术语解释事情,使它更容易学习。对于线型和块,您也可以在Afralisp上找到编码。您可以根据自己的需要对其进行优化。
此代码处理大多数通用实体的颜色设置。
我刚把长名字从ColorToLayer改了。lsp到CTL。lsp。
- ;CODING BEGINS HERE
- (defun c:CTL ()
- (setq i 0 n 0) ;clear the loop control variables
- (prompt "\n Select entities to analyze ") ;prompt the user
- (setq sel (ssget)) ;get the selection set
- (setq n (sslength sel)) ;get the number of objects
- (repeat n ;start the loop
- (setq entity (ssname sel i)) ;get the entity name
- (setq name (entget entity)) ;now get the entity list
- (if (not (assoc 6 name)) ;if not Bylayer
- (progn ;do the following
- (setq layer (cdr (assoc 8 name))) ;retrieve the layer name
- (setq layerinf (tblsearch "LAYER" layer)) ;get the layer data
- (setq layercol (cdr (assoc 62 layerinf))) ;extract the default layer colour
- (setq name (append name (list (cons 62 layercol)))) ;construct an append the new list
- (entmod name) ;update the entity
- (entupd entity) ;update the screen
- ) ;progn
- ) ;if
- (setq i (1+ i)) ;increment the counter
- ) ;repeat
- (princ)) ;defun
- (princ)
- ;CODING END HERE
|