variante con prefissi 0
(defun c:test ( / c n nl k kl pref name )
(setq c 0 k 0 pref "")
(initget 7)
(if (setq n (getint "\nNumber of Layers: ") nl (strlen (itoa n)))
(while (< k n)
(setq k (1+ k) kl (strlen (itoa k)))
(repeat (- nl kl)
(setq pref (strcat "0" pref))
)
(setq name (strcat pref (itoa k)))
(entmake
(list
'(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 name)
(cons 62 (setq c (1+ (rem c 256))))
'(70 . 0)
)
)
(setq pref "")
)
)
(princ)
)