RenderMan的代码很好。。。我稍微修改了一下:
- (vl-load-com)
- (defun c:splitlayersbycolor (/ *error* ss acDoc layerName)
- (defun *error* (msg)
- (if acDoc (vla-endundomark acDoc))
- (cond ((not msg)) ; Normal exit
- ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
- ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
- )
- (princ)
- )
- (if (setq ss (ssget "_:L"))
- (progn
- (vla-startundomark
- (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
- )
- (vlax-for x (setq ss (vla-get-activeselectionset acDoc))
- (if
- (not (tblsearch "layer"
- (setq layerName (strcat (vla-get-layer x)
- " "
- (itoa (vla-get-color x))
- )
- )
- )
- )
- (progn
- (vla-add (vla-get-layers acDoc) layerName)
- (vla-put-truecolor (vla-item (vla-get-layers acDoc) layerName) (vla-get-truecolor x))
- (vla-put-color x 256)
- )
- )
- (vla-put-layer x layerName)
- )
- (vla-delete ss)
- )
- )
- (*error* nil)
- )
M、 R。
现在,通过拆分创建的层中的对象都具有颜色“ByLayer”,并且拆分层的颜色已更改为引用实体的颜色,就像我在上一篇文章中解释的那样。。。 |