- ;;加载线型
- (defun JZXX ()
- (or (TBLSEARCH "LTYPE" "CENTER,DASHED,FENCELINE1,FENCELINE2,PHANTOM") ;搜索是否存在线型
- (vl-catch-all-apply
- 'vla-load
- (list (vla-get-Linetypes
- (vla-get-ActiveDocument (vlax-get-acad-object))
- )
- "CENTER,DASHED,FENCELINE1,FENCELINE2,PHANTOM"
- (findfile "acadiso.lin")
- ) ;不存在则加载线型
- )
- )
- )
- (defun li-xjtc (cm ys xx xk dy / ss lts )
- (JZXX) ;加载线型
- (Princ "\<<<<图层切换程序>>>>")
- (setvar "cmdecho" 0)
- (if (= (tblsearch "layer" cm) nil)
- (entmake
- (list
- '(0 . "LAYER")
- '(100 . "AcDbSymbolTableRecord")
- '(100 . "AcDbLayerTableRecord")
- '(70 . 0) ;图层状态
- (cons 2 cm) ;图层名称
- (cons 62 ys) ;图层颜色
- (cons 6 xx) ;图层线型
- (cons 370 xk) ;图层线宽:100=1, 15=0.15, 18=0.18, -3=默认
- (cons 290 dy) ;0-不打印,1-打印
- )
- )
- )
- (setq ss (ssget))
- (if (= ss nil)
- (setvar "clayer" cm) ;没有对象就切换至指定图层
- (command "chprop" ss "" "la" cm "c" "bylayer" "lt" "bylayer" "") ;有对象就将对象改至指定图层
- )
- (princ)
- )
- ;;;主程序
- (defun c:00 (/) (li-xjtc "0" 7 "continuous" -3 1)) ;切换至 "0" 图层
- (defun c:01 (/) (li-xjtc "01-DIM" 3 "continuous" 18 1)) ;切换至 "01-DIM" 图层
- (defun c:02 (/) (li-xjtc "02-TXT" 7 "continuous" -3 1)) ;切换至 "02-TXT" 图层
- (defun c:03 (/) (li-xjtc "03-Center" 1 "CENTER" 15 1)) ;切换至 "03-Center" 图层
- (defun c:04 (/) (li-xjtc "04-Hidden" 8 "DASHED" -3 1)) ;切换至 "04-Hidden" 图层
- (defun c:05 (/) (li-xjtc "05-Hatch" 2 "continuous" -3 1)) ;切换至 "05-Hatch" 图层
|