;;;------------------------------------------------------------;;;
;;; By WETANKS
;;; Version 1 - 6-09-2024
;;;------------------------------------------------------------;;;
(defun C:WE_SN ( / N1 K1 NM PT TT PT XX YY i)
(setq N1 (getint "\nEnter the number of points: "))
(setq K1 '())
(setq i 1)
(while (<= i N1)
(setq K1 (append K1 (list i)))
(setq i (1+ i))
)
(setq PT (getpoint "\nSelect starting point: "))
(setq XX (getreal "\nEnter X direction spacing: "))
(setq YY (getreal "\nEnter Y direction spacing: "))
(setq NM 1)
(setq pt PT)
(while (> N1 0)
(setq TT (car K1))
(setq K1 (cdr K1))
(command "text" "j" "m" pt 30 "0" TT)
(setq N1 (1- N1))
(setq pt (list (+ (car pt) XX) (+ (cadr pt) YY)))
)
(princ)
)
;;;------------------------------------------------------------;;;
;;; End of File
;;;------------------------------------------------------------;;;
Solved! Go to Solution.
Solved by exceeds. Go to Solution.
한글로 설명을 붙이자면
입력한 횟수만큼 1부터 연속 번호 텍스트를 생성하는 리습으로
시작점, x축 간격, y축 간격을 입력해서 작동합니다.
index로 i를 사용하기 때문에, 바로 i를 출력 텍스트에 이용하면 리스트 없이 하나의 while이나 repeat으로도 만들 수 있으나
while 구문의 사용법이나, append로 list를 만들고 그걸 이용하는 방법을 보여주신 듯 합니다.
포인트 3가지는
(setq pt PT) autolisp은 변수 명의 대소문자를 구분하지 않기 때문에 아무 일도 일어나지 않습니다.
별도의 스타일 지정 없이 text를 생성하므로, 현재 텍스트 스타일대로 생성되며
command 를 사용하므로, 코드 시작에 (setvar 'cmdecho 0), 끝에 (setvar 'cmdecho 1)을 넣어주면
커맨드 프롬프트에 출력 없이 조용하게 돌아갑니다.
응용하자면
시작번호를 지정하거나, +1 이외에 더하기 빼기 할 차이 값을 지정하거나, 생성 시마다 위치를 새로 지정하거나,
앞글자, 뒷글자를 붙이거나, 알파벳으로 연속 생성하거나, 원 등의 테두리를 생성하는 방법이 있겠습니다.
Can't find what you're looking for? Ask the community or share your knowledge.