只通过 55# 所举例子
- ;;; 计算两点的中点
- (defun mpt (mpt1 mpt2)
- (polar mpt1 (angle mpt1 mpt2) (/ (distance mpt1 mpt2) 2))
- )
- (defun Dvl (ptLst / pxs)
- (foreach pts Ptlst
- (setq p5 (apply 'mpt pts)
- px (car p5)
- pxs (cons px pxs)
- p6 (list px y0)
- )
- (entmake (list '(0 . "LINE") (cons 10 p6) (cons 11 p5)))
- (ssadd (entlast) ss3)
- )
- pxs
- )
- (defun gt2Pts (a)
- (list
- (vlax-curve-getStartPoint a)
- (vlax-curve-getEndPoint a)
- )
- )
- (defun findV (ss / ptss)
- (setq nn (sslength ss)
- nn (1- nn)
- )
- (while (setq ee (ssname ss nn))
- (setq pts (gt2Pts ee)
- dd (apply 'mapcar (cons '- pts))
- dd (mapcar 'abs dd)
- nn (1- nn)
- )
- (if (equal (car dd) (cadr dd) 1e-4)
- (setq ptss (cons pts ptss))
- ) )
- ptss
- )
- (defun c:test ()
- (setq ss (ssget))
- (command "PEDIT" "M" ss "" "Y" "J" "" "")
- (setq eepl (entlast))
- (command "Explode" eepl)
- (setq ss (ssget "P")
- ss2 (findV ss)
- ss3 (ssadd)
- )
- (command "PEDIT" "M" ss "" "Y" "J" "" "")
- (setq eepl (entlast))
- (vla-getboundingbox (vlax-ename->vla-object eePl) 'minpt 'maxpt)
- (setq ;; eepl (entlast)
- ;; pts (acet-ent-geomextents eePl)
- pts (list (vlax-safearray->list minpt) (vlax-safearray->list maxpt))
- p1 (car pts)
- p3 (cadr pts)
- x0 (car p1)
- x9 (car p3)
- y0 (cadr p1)
- y5 (+ y0 2)
- pa (list (+ x0 1) y5)
- nxtx (cdr (Dvl ss2))
- )
- (setvar "OsMode" 0)
- (command "boundary" pa)
- (while (setq pbx (car nxtx))
- (setq nxtx (cddr nxtx)
- pb (list (+ pbx 1) y5)
- )
- (command pb)
- )
- (command "")
- (setq ss2 (ssget "w" p1 p3))
- (command "erase" eepl ss3 "")
- )
|