马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [FONT=courier new]
- (defun mergelays (lay1 lay2 / cnt space blocks attrs)
- (command "-layer" "u" lay1 "")
- (setq blocks (vla-get-blocks (vla-get-activedocument
- (vlax-get-acad-object)
- )
- )
- )
- (setq cnt 0)
- (while (< cnt (vla-get-count blocks))
- (setq space (vla-item blocks cnt))
- (vlax-for itm space (if (= (strcase (vla-get-layer itm))
- (strcase lay1)
- )
- (vla-put-layer itm lay2)
- ) (if (and
- (= (vla-get-objectname itm)
- "AcDbBlockReference"
- )
- (= (vla-get-hasattributes itm) :vlax-true)
- )
- (progn
- (setq attrs (vlax-safearray->list
- (vlax-variant-value
- (vla-getattributes itm)
- )
- )
- )
- (foreach attr attrs
- (if (= (strcase (vla-get-layer attr))
- (strcase lay1)
- )
- (vla-put-layer attr lay2)
- )
- )
- )
- )
- )
- (setq cnt (1+ cnt))
- )
- (if (= (getvar "CLAYER") lay1)
- (setvar "CLAYER" lay2)
- )
- (command "_.purge" "lay" lay1 "_n")
- (princ)
- )
- [/FONT]
|