Hi Alls,
Here my code to create an atribute block, but this code still trouble at function in block, because if you create in manual system you would get attribut dialog before finish it.
; cad is stand for Create Attribute Definition
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 15 March 2007
; Program no.: 0559/03/2007
; Edit by : Adesu 12/06/2007 1).
; 13/06/2007 2).
(defun c:cad (/ ad ang cnt etyp ht prom rot sp ss sse ssl ssn str tag th val)
(setq ad (getvar "attdia"))
(if
(= ad 1)
(setvar "attdia" 0)
) ; if
(princ "\nSelect by polygon alls text")
(if
(setq ss (ssget '((0 . "TEXT"))))
(progn
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(setq sse (entget ssn))
(setq etyp (cdr (assoc 0 sse)))
(if
(= etyp "TEXT")
(progn
(setq sp (cdr (assoc 10 sse)))
(setq str (cdr (assoc 1 sse)))
(setq ht (cdr (assoc 40 sse)))
(setq ang (cdr (assoc 50 sse)))
(setq tag
(getstring t
(strcat "\nEnter name for tag< " str " >: ")))
(setq prom
(getstring t
(strcat "\nEnter name for prompt< " str " >: ")))
(setq val str)
(setq th (getdist (strcat "\nEnter new text height< " (rtos ht) " >: ")))
(if (= th nil)(setq th ht))
(setq rot (getdist (strcat "\nEnter new rotation< " (rtos ang) " >: ")))
(if (= rot nil)(setq rot ang))
(command "_attdef" "i" "" tag prom val sp th rot)
) ; progn
) ; if
(setq cnt (1+ cnt)) ; 1).
) ; repeat
) ; progn
) ; if
(setq path "D:/YBI/Drawing/Data Base/Block/") ; 2).
(setq bn (getstring t "\nEnter name for block: ")) ; 1).
(setq loc (strcat path bn)) ; 2).
(setq bp (getpoint "\nClick as base point block: ")) ; 1).
(prompt "\nSelect object would become block")
(setq ss (ssget))
(command "_-block" bn "" bp ss "")
(setq pt (getpoint "\nClick any location: ")) ; 2).
(command "insert" bn pt "" "" "") ; 2).
(setvar "attdia" ad)
(princ)
) ; defun