Hi Alls,
here my code to create a show loading in picture,that code would create
1). create a circle with line from center to circumfence line of circle,first line create from center to top of circle,then create as counter clock wise.
2). create a text from 0.00 to 100 %
From poin no.1 and no.2 should be same display,but this fact my code got trouble to display both,especially line in inner circle and display of value string over from 100 %.
; slip is stand for Show Loading In Picture
(defun c:slip (/ % ang cnt ed len len_pro loc num num_pre
num_real p1 p2 p3 pro rad sse ssn sst str
txt xstr)
(command "_viewres" "y" 10000 "")
(setq loc '(0 0 0))
(setq rad 5)
(command "_circle" loc rad "")
(setq p2 (polar loc (* pi 1.5) 7.5))
(setq p3 (polar p2 pi 5))
(setq str "Progress : 0.00 %")
(command "_text" p3 1 "" str 0 "")
(command "_zoom" "e")
(setq ang 0)
(repeat
6300
(setq p1 (polar loc (+ (* pi 0.5) ang) rad))
(command "_line" loc p1 "")
(setq ang (+ ang 0.001))
(setq sst (ssget "x" '((0 . "TEXT"))))
(setq ssn (ssname sst 0))
(setq sse (entget ssn))
(setq txt (cdr (assoc 1 sse))) ; "Progress : 0.00 %"
(setq len (strlen txt)) ; 17
(setq len_pro 12) ; 12
(if
(= len 17) ; T
(progn
(setq num_pre (- len (+ len_pro 1))) ; 4
(setq num_real (- len 5)) ; 12
(setq pro (substr txt 1 (- len 6))) ; "Progress : "
(setq num (substr txt num_real num_pre)) ; "0.00"
(setq % (substr txt len 1)) ; "%"
) ; progn
) ; if
(if
(= len 18) ; T
(progn
(setq num_pre (- len (+ len_pro 1))) ; 4
(setq num_real (- len 6)) ; 12
(setq pro (substr txt 1 (- len 7))) ; "Progress : "
(setq num (substr txt num_real num_pre)) ; "10.0"
(setq % (substr txt len 1)) ; "%"
) ; progn
) ; if
(if
(= len 19) ; T
(progn
(setq num_pre (- len (+ len_pro 1))) ; 3
(setq num_real (- len 7)) ; 12
(setq pro (substr txt 1 (- len 8))) ; "Progress : "
(setq num (substr txt num_real num_pre)) ; "100"
(setq % (substr txt len 1)) ; "%"
) ; progn
) ; if
(setq cnt 0.015223015)
(setq num (rtos (+ (distof num) cnt) 2 2))
(setq xstr (strcat pro num " " %))
(setq ed (entmod (subst (cons 1 xstr)(assoc 1 sse) sse)))
) ; repeat
;(setq ssc (ssget "x" '((0 . "CIRCLE,TEXT,LINE"))))
;(command "_erase" ssc "")
(princ)
) ; defun