(while t (setq pnt (getpoint "\n>>>☞ 텍스트 Pick Point : ")) (if (= pnt nil) (progn (princ "\nExiting...\n") (exit)) ;; Exit the loop if Enter is pressed (if (= pnt "Change") (setq txtinput (getstring "\nEnter New Text: ")) (progn ;; Create text with prefix and optionally incremented number (if hasnum (setq txt (strcat prefix (itoa addnum))) (setq txt prefix) )
;; Increment for the next loop if numbering is used (if hasnum (setq addnum (1+ addnum)) )
;; Create text entity to measure its dimensions (command "text" "j" "m" pnt txth "0" txt) (setq txtent (entlast)) (setq txtwidth (* (strlen txt) (* 1.0 txth))) ;; Approximation of text width (setq txtheight txth)
;; Set text color (command "chprop" txtent "" "color" color "")
(setq bh (* 2.0 txtheight)) (cond ((= cbn "Circle") (progn (command "CIRCLE" pnt (* 0.75 (max txtwidth txtheight))) ;; Set circle color to red (command "chprop" (entlast) "" "color" 1 "") ) ) ((= cbn "Box") (progn (setq boxsize (max txtwidth txtheight)) (setq lu (list (- (car pnt) (* 1.0 boxsize)) (+ (cadr pnt) (* 1.0 boxsize)))) (setq ru (list (+ (car pnt) (* 1.0 boxsize)) (+ (cadr pnt) (* 1.0 boxsize)))) (setq rl (list (+ (car pnt) (* 1.0 boxsize)) (- (cadr pnt) (* 1.0 boxsize)))) (setq ll (list (- (car pnt) (* 1.0 boxsize)) (- (cadr pnt) (* 1.0 boxsize)))) (command "pline" lu ru rl ll "c") ;; Set box color to red (command "chprop" (entlast) "" "color" 1 "") ) ) ((= cbn "Triangle") (progn (setq h (* 0.25 bh)) ; 정삼각형 높이 (setq bh (/ txtwidth 0.65)) ; 삼각형 한 변의 길이 (setq top (list (car pnt) (+ (cadr pnt) (* 0.866 bh)))) (setq left (list (- (car pnt) bh) (- (cadr pnt) (* 0.866 bh)))) (setq right (list (+ (car pnt) bh) (- (cadr pnt) (* 0.866 bh))))
;; 기존 텍스트 제거 및 삼각형의 중심에 텍스트 배치 (entdel txtent) (command "text" "j" "m" mid txth "0" txt) (command "chprop" (entlast) "" "color" color "")
(command "pline" top left right "c") ;; Set triangle color to red (command "chprop" (entlast) "" "color" 1 "") ) ) ) ) ) ) ) (setq *error* oer seterr nil) (princ) ) (vl-load-com)