本帖最后由 newer 于 2018-3-27 01:13 编辑
按照marting的思路,API写了个
XD::Pnts:Extremum 函数见:http://bbs.xdcad.net/thread-715128-1-1.html
 - (defun c:tt ()
- (setq tf t)
- (while (and tf
- (setq e
- (car
- (xdrx_entsel "\n拾取最外边界<退出>:" '((0 . "*line,circle,ellipse")))
- )
- )
- )
- (if (xdrx_curve_isclosed e)
- (setq tf nil)
- (xdrx_prompt "\n边界不闭合,重选.")
- )
- )
- (if (and (not tf)
- (setq pts (xdrx_getsamplept e))
- (setq ss (ssget "wp" pts '((0 . "*polyline,circle,ellipse"))))
- )
- (progn
- (xdrx_begin)
- (mapcar
- '(lambda (x)
- (if (xdrx_curve_isclosed x)
- (progn (setq typ (car (xdrx_object_classname x)))
- (cond ((wcmatch typ "CIRCLE,ELLIPSE")
- (setq pt (nth 3 (xdrx_entity_getgrippoint x)))
- )
- ((= typ "SPLINE"))
- ((wcmatch typ "*POLYLINE")
- (setq pts (xdrx_getpropertyvalue x "vertices")
- pt (xd::pnts:extremum pts '> '> t)
- )
- )
- )
- (if (and (setq gray (xdge::constructor "kRay3d"
- pt
- (polar pt (/ pi 2.0) 1.0)
- )
- )
- (setq ints (xdrx_entity_intersectwith gray e))
- (setq ints (car ints))
- (or (setq ss1 (ssget "f"
- (list pt ints)
- '((0 . "CIRCLE,ELLIPSE,*POLYLINE"))
- )
- )
- (progn (setq ss1 (ssadd)) (ssadd e ss1) t)
- )
- )
- (progn (ssdel x ss1)
- (ssadd e ss1)
- (setq ints (xdrx_getinters (list pt ints) ss1)
- ints (xdrx_points_sortoncurve gray ints)
- ints (caar ints)
- )
- (xdrx_line_make pt ints)
- )
- )
- (xdge::free gray)
- )
- )
- )
- (xdrx_pickset->ents ss)
- )
- (xdrx_end)
- )
- )
- (princ)
- )
|