本帖最后由 作者 于 2004-9-21 15:05:22 编辑
- (defun tls-getarea( / l1 l2 i pnts ss1 ss2 area)(defun tls-ssr(ss1 ss2 / i)
- (setq i 0)
- (repeat (sslength ss2)
- (ssdel (ssname ss2 i) ss1)
- (setq i (1+ i))
- )
- )(defun tls-breakatpnts(ent pnts / i lst count pnt)
- (setq i 0 lst nil count (/ (length pnts) 3))
- (repeat count
- (setq
- pnt (list (nth i pnts) (nth (1+ i) pnts) (nth (+ i 2) pnts))
- pnt (cons (vlax-curve-getdistatpoint ent pnt) (list pnt))
- lst (cons pnt lst)
- i (+ i 3)
- )
- )
- (setq lst
- (vl-sort lst
- (function (lambda (e1 e2) (> (car e1) (car e2))))
- )
- )
- (setq i -1)
- (repeat count
- (setq pnt (cadr (nth (setq i (+ i 1)) lst)))
- (command "_.break" (list ent pnt) pnt)
- )
- ) (setvar "cmdecho" 0)
- (setq
- l1 (car (entsel))
- l2 (car (entsel))
- pnts
- (vlax-safearray->list (vlax-variant-value (vla-IntersectWith
- (vlax-ename->vla-object l1)
- (vlax-ename->vla-object l2)
- acExtendNone)))
- ss1 (ssget "X")
- )
- (if (> (length pnts) 4)
- (progn
- (ssdel l1 ss1)
- (ssdel l2 ss1)
- (command "_.undo" "be")
- (setq i 0)
- (tls-breakatpnts l1 pnts)
- (tls-breakatpnts l2 pnts)
- (setq ss2 (ssget "X"))
- (tls-ssr ss2 ss1)
- (command "region" ss2 "")
- (setq ss2 (ssget "X" '((0 . "REGION"))))
- (tls-ssr ss2 ss1)
- (setq i 0 area 0)
- (repeat (sslength ss2)
- (setq area (+ area (vla-get-area (vlax-ename->vla-object (ssname ss2 i)))))
- (setq i (1+ i))
- )
- (command "_.undo" "e")
- (command "_.undo" "1")
- (setvar "cmdecho" 1)
- )
- )
- area
- )
|