我的尝试
- ; pline co-ords example
- ; By Alan H
- (defun getcoords (ent)
- (vlax-safearray->list
- (vlax-variant-value
- (vlax-get-property
- (vlax-ename->vla-object ent)
- "Coordinates"
- )
- )
- )
- )
- (defun co-ords2xy ()
- ; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
- (setq len (length co-ords))
- (setq numb (/ len 2)) ; even and odd check required
- (setq I 0)
- (repeat numb
- (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
- ; odd (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
- (setq co-ordsxy (cons xy co-ordsxy))
- (setq I (+ I 2))
- )
- )
- ; program starts here
- (defun c:labelpoly ( / ent x y co-ordsxy pt )
- (while (setq ent (car (entsel "\nPlease pick pline <Cr> to exit")))
- (setq co-ords (getcoords ent))
- (co-ords2xy) ; list of 2d points making pline
- (setq co-ordsxy (reverse co-ordsxy))
- (setq x (Getint "Enter start number"))
- (setq y 0)
- (repeat (length co-ordsxy)
- (setq pt (list (nth 0 (nth y co-ordsxy))(nth 1 (nth y co-ordsxy))))
- (if (< x 10)
- (setq newstr2 (strcat "0" (rtos x 2 0)))
- (setq newstr2 (rtos x 2 0))
- )
- (command "-text" pt 2.5 90 newstr2)
- (command "circle" pt 5)
- (setq y (+ y 1))
- (setq x (+ x 1))
- )
- )
- )
|