- (defun c:tt ()
- "图元分层"
- (defun dxf (code e) (cdr (assoc code (entget e))))
- (defun SubUpd (e c v)
- (entmod (subst (cons c v) (assoc c (entget e)) (entget e)))
- (entupd e)
- )
- (defun mklaco (la co)
- (entmake (list '(0 . "LAYER")
- '(100 . "AcDbSymbolTableRecord")
- '(100 . "AcDbLayerTableRecord")
- (cons 62 co) ;颜色
- (cons 2 la) ;图层名
- )
- )
- )
- (if (setq ss (ssget '((8 . "~穿线孔")))) ; 排除特定图层
- (progn
- (mklaco "XG-LAYER01" 1)
- (mklaco "XG-CENTER" 5)
- (mklaco "XG-BHATCH" 8)
- (mklaco "XG-TXT" 3)
- (mklaco "XG-DIM" 7)
- (setq i -1)
- (repeat (setq nn (sslength ss))
- (setq s1 (ssname ss (setq i (1+ i))))
- (setq et (strcase (DXF 0 s1)))
- (SubUpd s1 62 256) ; 图元颜色随层
- (cond ((wcmatch et "*DIMENSION,ACDBLEADER")
- (SubUpd s1 8 "XG-DIM")
- )
- ((wcmatch et "*TEXT")
- (SubUpd s1 8 "XG-TXT")
- )
- ((wcmatch et "HATCH")
- (SubUpd s1 8 "XG-BHATCH")
- )
- ((and (wcmatch et "CIRCLE,*LINE")
- (setq lt (DXF 6 s1))
- (wcmatch (strcase lt) "DASHED*,HIDDEN*")
- )
- (SubUpd s1 8 "XG-CENTER")
- )
- (t (SubUpd s1 8 "XG-LAYER01"))
- )
- )
- (princ (strcat "\n共有" (itoa nn) "个图元整理分层成功"))
- )
- )
- (princ)
- )
|