本帖最后由 夏生生 于 2021-12-25 17:35 编辑
仅适用于本例
- (defun c:tt (/ getmid en dis pt obj1 obj2)
- (defun getmid (en)
- (vlax-curve-getpointatparam
- en
- (* 0.5
- (+ (vlax-curve-getstartparam en)
- (vlax-curve-getendparam en)
- )
- )
- )
- )
- (setq en (vl-catch-all-apply
- (function vlax-safearray->list)
- (list (vlax-variant-value
- (vla-explode
- (vlax-ename->vla-object (car (entsel "\n选取:")))
- )
- )
- )
- )
- en (mapcar
- '(lambda (x)
- (list
- (vlax-curve-getdistatparam x (vlax-curve-getendparam x))
- (getmid x)
- x
- )
- )
- en
- )
- )
- (if (= 4 (length en))
- (progn
- (setq en (vl-sort en '(lambda (a b) (< (car a) (car b))))
- dis (* 0.5 (caar en))
- pt (mapcar '(lambda (x y) (* 0.5 (+ x y)))
- (cadr (caddr en))
- (cadr (last en))
- )
- )
- (setq obj1 (car (vl-catch-all-apply
- (function vlax-safearray->list)
- (list (vlax-variant-value
- (vla-offset (last (last en)) dis)
- )
- )
- )
- )
- obj2 (car (vl-catch-all-apply
- (function vlax-safearray->list)
- (list (vlax-variant-value
- (vla-offset (last (last en)) (- dis))
- )
- )
- )
- )
- )
- (if (equal pt (getmid obj1) 1e-4)
- (progn(vla-delete obj2)(vla-put-layer obj1(getvar"clayer")))
- (progn(vla-delete obj1)(vla-put-layer obj2(getvar"clayer")))
- )
- (foreach n en (vla-delete (last n)))
- )
- (progn(foreach n en (vla-delete (last n)))(alert"非四边"))
- )
- )
|