본문 바로가기
autocad

태그 블럭 안에 있는 해치 레이어 바꾸기

by kmlab 2026. 7. 6.

도어 태그 블럭 이름이 "Tag_Door_CUB_Ph-3*"로 시작하는 것들을 선택해서,
그 안에 있는 해치의 레이어를 "AA-GNRL_FUTUE"로 변경
WCMATCH 함수를 사용하는 것보다. SSGET으로 (CONS 2 이름에 wildcard 를 사용하는게 낫다.

(defun c:tgdh ( / wctgdn HLA tn n entn h SHT sheet p1 p2 scl P11 P22 hh) ; tag door hatch
(setq wctgdn "Tag_Door_CUB_Ph-3*") ;wctgdn is wildcard tag door block name
(setq HLA "AA-GNRL_FUTURE") ; name of LAYER of Hatch to change
(if 
	(setq tgdb (ssget "X" (list (cons 0 "INSERT") (cons 2 wctgdn))))
	(progn
		(setq tn (sslength tgdb))
		(setq n 0)
		(repeat tn
			(setq entn (cdr (assoc 2 (entget (ssname tgdb n)))))
			(command "-BEDIT" entn)
			(setq h (ssget "X" (list (cons 0 "HATCH"))))
			(command "_change" h "" "P" "LA" HLA "")
			(command "bclose" "sa")
			(setq n (1+ n))
		) ; repeat
	) ; progn
);if
(setq SHT "*Sheet_YI*")
(setq p1 '(740.6444 363.7849) p2 '(781.7177 373.7849))
(setq sheet (ssget "X" (list (cons 0 "INSERT" ) (cons 2 SHT))))
(setq scl (cdr (assoc 41 (entget (ssname sheet 0)))))
(setq P11 (list (* scl (car p1)) (* scl (cadr p1))))
(setq P22 (list (* scl (car p2)) (* scl (cadr p2))))
(command "zoom" "o" sheet "")
(setq hh (ssget "C" P11 P22 (list (cons 0 "HATCH"))))
(command "_change" hh "" "P" "LA" HLA "")
(princ)
) ; defun

SSGET으로 선택한 여러 개체들을 순서대로 선택하려면
NTH 함수는 안된다. NTH 함수는 리스트 중에서 원소를 선택할 때 사용하며, SSGET은 리스트를 리턴하지 않는다
SSGET으로 선택한 개체들은 SSNAME으로 순서대로 선택할 수 있다.

 

반응형