iDwgLsp 프로그램을 설치하면 구글 블로거에 등록된 리습코드를 구동 시켜주는 기능을 지원합니다. - 다운로드 사이트 : http://arx119.egloos.com/10973367 - 지원버전 오토캐드 (2007~2013)
2012년 12월 25일 화요일
[LISP-GSJ] 레이어 유틸리티 프로그램 (포스트아이디 : 6884277912232997583)
;;==========================================================================================================
;;==========================================================================================================
;;==========================================================================================================
;; 자 료 명 : Layer 관련 유틸
;; 파 일 명 : LayerUtil.LSP
;; 만 든 이 : 고 석 재
;; 명 령 어 : AN,AF,EN,EF,AU,AL,EU,EL,ED,CL,LC,EC
;;
;; http://cafe.daum.net/zwcad & http://www.lispcenter.net
;;
;;==========================================================================================================
;;==========================================================================================================
;; Layer 관련 명령
;;==========================================================================================================
;;==========================================================================================================
(defun C:AN(/ OnCount LayerCount LayerEntity LayerName)
(princ "\n전체 Layer 켜기")(princ)
(setq OnCount 0)
(setq LayerCount 0)
(setvar "cmdecho" 0)
(setq LayerEntity (tblnext "layer" t))
(setq LayerCount (+ LayerCount 1))
(while (setq LayerEntity (tblnext "layer"))
(setq LayerCount (+ LayerCount 1))
)
(command "Layer" "on" "*" "")
(princ (strcat "\n" (itoa LayerCount) " Layer ON"))
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(defun C:AF(/ OnCount LayerCount LayerEntity LayerName)
(princ "\n전체 Layer 끄기")(princ)
(setq OnCount 0)
(setq LayerCount 0)
(setvar "cmdecho" 0)
(setq CurrentLayer (getvar "CLayer"))
(setq LayerEntity (tblnext "layer" t))
(setq LayerName (cdr (assoc 2 LayerEntity)))
(setq LayerCount (+ LayerCount 1))
(while (setq LayerEntity (tblnext "layer"))
(setq LayerCount (+ LayerCount 1))
)
(command "layer" "OFF" "*" "Y" "")
(princ (strcat "\n" (itoa LayerCount) " Layer OFF"))
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(defun C:EN(/ OffCount OnCount LayerCount TempNum CurrentLayer OnLayerSet LayerEntity LayerName)
(princ "\n선택된 Layer만 켜고 모든 Layer 끄기")(princ)
(setq OffCount 0)
(setq OnCount 0)
(setq LayerCount 0)
(setq TempNum 0)
(setvar "cmdecho" 0)
(setq CurrentLayer (getvar "CLayer"))
(setq OnLayerSet (ssget))
(if (/= OnLayerSet nil)
(progn
;;=======================================================================================================
;; 모든 Layer OFF
(setq LayerEntity (tblnext "layer" t))
(setq LayerCount (+ LayerCount 1))
(while (setq LayerEntity (tblnext "layer"))
(setq LayerCount (+ LayerCount 1))
)
(command "layer" "OFF" "*" "Y" "")
;;=======================================================================================================
;; 선택된 Layer ON
(repeat (sslength OnLayerSet)
(setq LayerName (cdr (assoc 8 (entget (ssname OnLayerSet TempNum)))))
(if (> 0 (cdr (assoc 62 (tblsearch "layer" LayerName))))
(progn
(setq OnCount (+ OnCount 1))
(command "layer" "ON" LayerName "")
)
)
(setq TempNum (+ TempNum 1))
)
;;=======================================================================================================
(princ (strcat "\n" (itoa OnCount) " Layer ON , " (itoa (- LayerCount OnCount)) " Layer OFF"))
)
(princ (strcat "\n0 Layer OFF"))
)
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(defun C:EF(/ OffCount LayerCount TempNum CurrentLayer OnLayerSet LayerEntity LayerCount)
(princ "\n선택된 Layer 끄기")(princ)
(setq OffCount 0)
(setq LayerCount 0)
(setq TempNum 0)
(setvar "cmdecho" 0)
(setq CurrentLayer (getvar "CLayer"))
(setq LayerEntity (tblnext "layer" t))
(setq LayerCount (+ LayerCount 1))
(while (setq LayerEntity (tblnext "layer"))
(setq LayerCount (+ LayerCount 1))
)
(setq OnLayerSet nil)
(setq OnLayerSet (entsel "\nSelect Layer :"))
(while (/= OnLayerSet nil)
(setq LayerName (cdr (assoc 8 (entget (car OnLayerSet)))))
(if (= LayerName CurrentLayer)
(command "layer" "OFF" LayerName "Y" "")
(command "layer" "OFF" LayerName "")
)
(setq OffCount (+ OffCount 1))
(setq OnLayerSet (entsel "\nSelect Layer :"))
)
;;=======================================================================================================
(princ (strcat "\n" (itoa OffCount) " Layer OFF"))
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(defun C:AU(/ OnCount LayerCount LayerEntity LayerName)
(princ "\n전체 Layer 잠금 해제")(princ)
(setq OnCount 0)
(setq LayerCount 0)
(setvar "cmdecho" 0)
(setq LayerEntity (tblnext "layer" t))
(setq LayerName (cdr (assoc 2 LayerEntity)))
(setq LayerCount (+ LayerCount 1))
(if (<= 4 (cdr (assoc 70 (tblsearch "Layer" LayerName))))
(progn
(command "layer" "U" LayerName "")
(setq OnCount (+ OnCount 1))
)
)
(while (setq LayerEntity (tblnext "layer"))
(setq LayerName (cdr (assoc 2 LayerEntity)))
(setq LayerCount (+ LayerCount 1))
(if (<= 4 (cdr (assoc 70 (tblsearch "Layer" LayerName))))
(progn
(command "layer" "U" LayerName "")
(setq OnCount (+ OnCount 1))
)
)
)
(princ (strcat "\n" (itoa LayerCount) " Layer UnLock"))
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(defun C:AL(/ OnCount LayerCount LayerEntity LayerName)
(princ "\n전체 Layer 잠금")(princ)
(setq OnCount 0)
(setq LayerCount 0)
(setvar "cmdecho" 0)
(setq CurrentLayer (getvar "CLayer"))
(setq LayerEntity (tblnext "layer" t))
(setq LayerName (cdr (assoc 2 LayerEntity)))
(setq LayerCount (+ LayerCount 1))
(command "layer" "LO" LayerName "")
(setq OnCount (+ OnCount 1))
(while (setq LayerEntity (tblnext "layer"))
(setq LayerName (cdr (assoc 2 LayerEntity)))
(setq LayerCount (+ LayerCount 1))
(command "layer" "LO" LayerName "")
(setq OnCount (+ OnCount 1))
)
(princ (strcat "\n" (itoa OnCount) " Layer Lock"))
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(defun C:EU(/ OnCount LayerCount LayerEntity LayerName)
(princ "\n선택된 Layer 잠금 해제")(princ)
(setq OnCount 0)
(setq LayerCount 0)
(setvar "cmdecho" 0)
(setq TempNum 0)
(setq OnLayerSet nil)
(setq OnLayerSet (entsel "\nSelect Layer :"))
(while (/= OnLayerSet nil)
(setq LayerName (cdr (assoc 8 (entget (car OnLayerSet)))))
(setq LayerState (cdr (assoc 70 (tblsearch "layer" LayerName))))
(if (<= 4 LayerState)
(progn
(command "layer" "U" LayerName "")
(setq OnCount (+ OnCount 1))
)
)
(setq OnLayerSet (entsel "\nSelect Layer :"))
)
(princ (strcat "\n" (itoa OnCount) " Layer UnLock"))
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(defun C:EL(/ OnCount LayerCount LayerEntity LayerName)
(princ "\n선택된 Layer 잠금")(princ)
(setq OnCount 0)
(setq LayerCount 0)
(setvar "cmdecho" 0)
(setq TempNum 0)
(setq OnLayerSet nil)
(setq OnLayerSet (entsel "\nSelect Layer :"))
(while (/= OnLayerSet nil)
(setq LayerName (cdr (assoc 8 (entget (car OnLayerSet)))))
(setq LayerState (cdr (assoc 70 (tblsearch "layer" LayerName))))
(command "layer" "LO" LayerName "")
(setq OnCount (+ OnCount 1))
(setq OnLayerSet (entsel "\nSelect Layer :"))
)
(princ (strcat "\n" (itoa OnCount) " Layer Lock"))
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(defun C:ED(/ CurrentLayer LayerEntity LayerName EntityALL EntityCount LayerState LayerUnLock)
(princ "\n선택된 Layer가 적용된 객체 삭제")(princ)
(setq EntityCount 0)
(setq LayerUnLock 1)
(setq LayerEntity (entsel "\nSelect Layer : "))
(if (/= LayerEntity nil)
(progn
(setq LayerName (cdr (assoc 8 (entget (car LayerEntity)))))
(setq LayerState (cdr (assoc 70 (tblsearch "Layer" LayerName))))
(if (< 0 LayerState) ;; 속성 해제
(command "layer" "U" LayerName "")
)
(if (= 1 LayerUnLock)
(progn
(setq EntityALL (ssget "X" (list (cons 8 LayerName)))) ;; 모든 엔티티 선택
(if (/= EntityALL nil)
(progn
(command "erase" EntityALL "")
(setq EntityCount (sslength EntityAll))
)
)
(princ (strcat "\n " LayerName " Layer " (itoa EntityCount) " Object Delete"))
)
)
)
)
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
;; Current Layer Setting
(defun C:CL(/ CurrentLayer LayerEntity LayerName)
(princ "\n선택 Layer를 현재 Layer 설정")(princ)
(setq CurrentLayer (getvar "clayer"))
(setq LayerEntity (entsel "\nSelect Layer : "))
(if (/= LayerEntity nil)
(progn
(setq LayerName (cdr (assoc 8 (entget (car LayerEntity)))))
(setvar "clayer" LayerName)
(princ (strcat "\nCurrent Layer" "\"" LayerName "\""))
)
)
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(defun EntLayerChange(iEntityName iLayerSetList / iEntityName iLayerSetList EntData EntLayer ChangeLayer)
;;-------------------------------------------------------------------------------------------
(setq iEntData (entget iEntityName))
;;-------------------------------------------------------------------------------------------
;; Layer Name
(setq iEntLayer (assoc 8 iEntData))
(setq iLayerName (nth 0 iLayerSetList))
(setq iLayerColor (nth 1 iLayerSetList))
(setq iLayerLType (nth 2 iLayerSetList))
(setq iEntData (subst (cons 8 iLayerName) iEntLayer iEntData)) ;; 변환
(entmod iEntData)
(setq iEntData (entget iEntityName))
;;-------------------------------------------------------------------------------------------
;; Color
(if (/= (assoc 62 iEntData) nil) ;; ByLayer이 아니면
(progn
(setq iEntColor (assoc 62 iEntData))
(setq iEntData (subst (cons 62 iLayerColor) iEntColor iEntData)) ;; 변환
)
(setq iEntData (append iEntData (list (cons 62 iLayerColor)))) ;; 변환
)
(entmod iEntData)
(setq iEntData (entget iEntityName))
;;-------------------------------------------------------------------------------------------
;; Line Type
(if (/= (assoc 6 iEntData) nil) ;; ByLayer이 아니면
(progn
(setq iEntLine (assoc 6 iEntData))
(setq iEntData (subst (cons 6 iLayerLType ) iEntLine iEntData)) ;; 변환
)
(setq iEntData (append iEntData (list (cons 6 iLayerLType)))) ;; 변환
)
(entmod iEntData)
;;-------------------------------------------------------------------------------------------
)
;;==========================================================================================================
;;==========================================================================================================
;; Layer To Layer
(defun C:LC(/ CurrentLayer LayerEntity LayerName)
(princ "\n선택 객체의 Layer 변경")(princ)
(setq LayerName nil)
(setq EntityName nil)
(setq EntityName (entsel "\nSelect Object :"))
(if (/= EntityName nil)
(setq LayerName (entsel "\nSelect Layer :"))
)
;;-------------------------------------------------------------------------------------------
(while (and (/= EntityName nil) (/= LayerName nil))
(setq LayerName (cdr (assoc 8 (entget (car LayerName )))))
(EntLayerChange (car EntityName) (list LayerName 256 "ByLayer"))
(setq EntityName (entsel "\nSelect Object :"))
(if (/= EntityName nil)
(setq LayerName (entsel "\nSelect Layer :"))
)
)
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
;; 선택된 객체들의 Layer 변경
(defun C:EC(/ CurrentLayer LayerEntity LayerName)
(princ "\n선택 객체들의 Layer 변경")(princ)
(setq LayerName nil)
(setq EntityName nil)
(setq EntitySet nil)
(setq EntList (list))
(setq EntitySet (ssget))
(if (/= EntitySet nil)
(setq LayerName (entsel "\nSelect Layer :"))
)
;;-------------------------------------------------------------------------------------------
(if (and (/= EntitySet nil) (/= LayerName nil))
(progn
(setq LayerName (cdr (assoc 8 (entget (car LayerName)))))
(setq EntityCount (sslength EntitySet))
(setq CountNum 0)
(repeat EntityCount
(setq EntityName (ssname EntitySet CountNum))
(EntLayerChange EntityName (list LayerName 256 "ByLayer"))
(setq CountNum (+ CountNum 1))
)
)
)
(princ)
)
;;==========================================================================================================
;;==========================================================================================================
(princ "\nhttp://cafe.daum.net/zwcad & http://www.lispcenter.net")
(princ)
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기
즐거운 하루되세요...^^