- by:edata
- (defun c:tt(/ ANG1 ANG2 ANG3 ANG4 CEN DS12 DS23 DS34 DS41 ENT LL LST M12 M23 M34 M41 OBJ P1 P2 P3 P4 RR SS X Y)
- ;;返回多段线顶点表
- (defun vertexs (ename / plist pp n)
- (setq obj (vlax-ename->vla-object ename))
- (setq plist (vlax-safearray->list
- (vlax-variant-value
- (vla-get-coordinates obj))))
- (setq n 0)
- (repeat (/ (length plist) 2)
- (setq pp (append pp (list (list (nth n plist)(nth (1+ n) plist)))))
- (setq n (+ n 2))
- )
- pp
- )
- (if(setq ss(ssget '((0 . "lwpolyline") (90 . 4)(70 . 1))))
- (while (setq ent(ssname ss 0))
- (progn
- (setq lst(vertexs ent)
- p1(car lst)
- p2(cadr lst)
- p3(caddr lst)
- p4(cadddr lst)
- ll(apply 'mapcar (list 'min p1 p2 p3 p4))
- rr(apply 'mapcar (list 'max p1 p2 p3 p4))
- p1 ll
- p3 rr
- p2 (list(car p3)(cadr p1))
- p4 (list(car p1)(cadr p3))
- cen(mapcar '(lambda(x y)(* (+ x y) 0.5)) p1 p3)
- m12(mapcar '(lambda(x y)(* (+ x y) 0.5)) p1 p2)
- m23(mapcar '(lambda(x y)(* (+ x y) 0.5)) p2 p3)
- m34(mapcar '(lambda(x y)(* (+ x y) 0.5)) p3 p4)
- m41(mapcar '(lambda(x y)(* (+ x y) 0.5)) p4 p1)
- ds12(distance p1 p2)
- ds23(distance p2 p3)
- ds34(distance p3 p4)
- ds41(distance p4 p1)
- ang1 0
- ang2 (* 0.5 pi)
- ang3 0
- ang4 (* 0.5 pi)
- )
- (entmake (list '(0 . "TEXT")'(72 . 1)(cons 73 1)(cons 50 ang1) (cons 1 (rtos ds12 2 2)) (cons 10 m12)(cons 11 m12) (cons 40 (* ds12 0.025))))
- (entmake (list '(0 . "TEXT")'(72 . 1)(cons 73 1)(cons 50 ang2) (cons 1 (rtos ds23 2 2)) (cons 10 m23)(cons 11 m23) (cons 40 (* ds12 0.025))))
- (entmake (list '(0 . "TEXT")'(72 . 1)(cons 73 3)(cons 50 ang3)(cons 1 (rtos ds34 2 2)) (cons 10 m34)(cons 11 m34) (cons 40 (* ds12 0.025))))
- (entmake (list '(0 . "TEXT")'(72 . 1)(cons 73 3)(cons 50 ang4) (cons 1 (rtos ds41 2 2)) (cons 10 m41)(cons 11 m41) (cons 40 (* ds12 0.025))))
- )
- (setq ss(ssdel ent ss))
- )
- )
- (princ)
- )
|