Community
오토캐드 AutoCAD - 한국어
프로그램에 관한 사용 방법, 기술, 정보 등을 검색하고, 질문을 통해 서로 도움을 주고 받을 수 있습니다.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoLISP(2): CONTINUOUS NUMBER

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
WeTanks
332 Views, 2 Replies

AutoLISP(2): CONTINUOUS NUMBER

WeTanks_0-1717889770281.png

;;;------------------------------------------------------------;;;
;;; 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 
;;;------------------------------------------------------------;;;

 

 

 

We.Tanks

EESignature

A couple of Fusion improvement ideas that could your vote/support:
図面一括印刷

2 REPLIES 2
Message 2 of 3
exceeds
in reply to: WeTanks

한글로 설명을 붙이자면

 

입력한 횟수만큼 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 이외에 더하기 빼기 할 차이 값을 지정하거나, 생성 시마다 위치를 새로 지정하거나, 

앞글자, 뒷글자를 붙이거나, 알파벳으로 연속 생성하거나, 원 등의 테두리를 생성하는 방법이 있겠습니다.

Message 3 of 3
WeTanks
in reply to: exceeds

You are right.
When I wrote LISP,
I deleted (setvar 'cmdecho 0) and (setvar 'cmdecho 1).

Because I think that without them, LISP will not have much impact.

We.Tanks

EESignature

A couple of Fusion improvement ideas that could your vote/support:
図面一括印刷

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums