;選択した円の周長を一括表記
;+++++++++++++
(defun C:CODE17 (/ Obj0 Ent0 Obj MyHandle ObjLength )
;+++++++++++++
    (princ "\n円を選択")
    (setq Obj (ssget (list (cons 0 "CIRCLE"))))
    (if (not(= Obj nil));円が選択されていたら・・・
        (progn
            (setq cnt 0
                    num (sslength Obj))
            ;------------
            (Command "OsnapCoord" "1" "-Layer" "M" "FlagLength" "")
            ;------------
            (while (< cnt num);
                (setq tmpl (ssname Obj cnt))
                (setq ed (entget tmpl))
                (setq MyHandle  (cdr (assoc 5 ed)));ハンドル名
                ;-----円の中心座標
                (setq Pt (cdr(assoc 10 ed)));
                (Command "lengthen" (handent MyHandle) "p" "100" "")
                (setq ObjLength (getvar "PeriMeter"))
                (Command
                    "ID" Pt
                    "Ucs" "w" 
                    "-MText"  "@"  "J" "MC" "@0,0"
                    (Strcat "L=" (rtos ObjLength)) ""
                    "Ucs" "p"
                    "Grips" "2"
                )	
                (setq cnt (1+ cnt))
            );while

        );progn
        ;円が選択されていなかったら・・・
        (alert "選択エラー：円が選択されていません") 
    ):if
    (princ)
)
