
- [FONT=courier new]
- ;;;I:EntSelF
- ;;;(entsel)和(ssget)的结合,与(entsel)不同,你可提供一个过滤器。与(ssget)不同,你可提供一个提示。
- ;;;参数
- ;;;Msg:选择提示字符串,或为空。Filter:(ssget)形式的过滤器,或为空。
- ;;;示例
- ;;;(I:EntSelF "polyline: " '((0 . "Polyline,LWPolyline")))
- ;;;注意
- ;;;以上例子将返回如下,如果多义线在选择框区域内:(<Entity name: 19bb188> (12.14 11.0767 0.0)),或者如无多义线则为空(nil)。
- ;;;在图形对象非常多的图形中该程序是非常有用的。
- ;;;作者
- ;;;[B][Color=Navy]R. Robert Bell[/Color][/B]
- (defun I:EntSelF
- (Msg ; selection prompt
- Filter ; filter list
- / EntN ; (entsel) list, or "Exit" string
- pbDist ; pickbox size in drawing units
- PtPick ; point of selection from (entsel)
- ssPick ; selection set
- ) ;_ closes variable declare
- (while (not EntN) ; while no selection (or no exit)
- (setq
- EntN (if Msg ; if selection prompt
- (entsel Msg) ; then (entsel) w/prompt
- (entsel) ; else plain (entsel)
- ) ;_ closes if
- ) ;_ closes setq
- (if (= (getvar "ErrNo") 52) ; if null response
- (setq EntN "Exit") ; then set flag to exit
- ) ;_ closes if
- ) ;_ closes while
- (cond
- ((/= EntN "Exit") ; if not exit
- (setq
- pbDist (abs ; return absolute number
- (/
- (*
- (/ ; get pixel ratio
- (getvar "PickBox")
- (cadr (getvar "ScreenSize"))
- )
- (getvar "ViewSize") ; apply to viewsize
- ) ;_ closes *
- (sin (* 0.25 pi)) ; at 45?
- ) ;_ closes /
- ) ;_ closes abs
- PtPick (cadr EntN) ; get point of pick
- ) ;_ closes setq
- (if (setq ssPick (ssget "_C" ; if entities in crossing
- (polar PtPick (* 1.25 pi) pbDist)
- (polar PtPick (* 0.25 pi) pbDist)
- Filter ; match filter, if any
- ) ;_ closes ssget
- ) ;_ closes setq
- (cons ; then return first entity as (entsel)
- (ssname ssPick 0)
- (list PtPick)
- ) ;_ closes cons
- ) ;_ closes if
- ) ;_ closes condition
- ) ;_ closes cond
- ) ;_ closes defun I:EntSelF[/FONT]
|