本帖最后由 lijiao 于 2017-10-20 15:26 编辑
- (defun c:aopl (/ AREA AREAS ENT I N PT PT1 PT2 PT3 PTS PTS0 SS VLANAME)
- (if (setq ss (ssget '((0 . "*POLYLINE") (70 . 1))))
- (progn
- (setq i -1)
- (repeat (sslength ss)
- (setq ent (ssname ss (setq i (1+ i))))
- (setq ent (vlax-ename->vla-object ent))
- (setq pts (vlax-get ent 'Coordinates ))
- (setq pts0 pts)
- (setq Area (vlax-get ent 'Area))
- (setq vlaname (vlax-get ent 'ObjectName))
- (if (= vlaname "AcDb3dPolyline")
- (setq n 3)
- (setq n 2)
- )
- (setq pt (getpt pts n))
- (setq pts (cadr pt)
- pt (car pt))
- (setq Areas '())
- (while (> (length pts) n)
- (setq pt1 (GETPT pts n)
- pts (cadr pt1)
- pt2 (GETPT pts n)
- )
- (setq pt3 (append pt (car pt1) (car pt2)))
- (vlax-put ent 'Coordinates pt3)
- (setq Areas (cons (vlax-get ent 'Area) Areas))
- )
- (vlax-put ent 'Coordinates pts0)
- (if (not (equal Area (apply '+ Areas) 0.001))
- (vlax-put ent 'color 1)
- )
- )
- )
- )
- (princ)
- )
- (defun getpt (pts n / out)
- (repeat n
- (setq out (cons (car pts) out)
- pts (cdr pts))
- )
- (list (reverse out) pts)
- )
|