- 积分
- 73549
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2002-5-7 22:50:00
|
显示全部楼层
程序如内,执行命令getline
(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 "ickBox")
(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
(defun c:getline(/ filne flineent spntfl epntfl sliness sel_num count slineent spntsl epntsl)
(setq fline(I:EntSelF "选择直线: " '((0 . "line"))) )
(setq flineent(entget (car fline)))
(setq spntfl(cdr (assoc 10 flineent)))
(setq epntfl(cdr (assoc 11 flineent)))
(entdel (car fline))
(setq sliness(ssget "f" (list spntfl epntfl) '((0 . "line"))))
(if (not sliness)
(progn
(princ "\n没有直线与选定的直线相交")
)
(progn
(setq sel_num (sslength sliness))
(princ (strcat "\n有" (itoa sel_num) "条直线与选定的直线相交,以下为交点的列表:"))
(setq count 0)
(repeat sel_num
(setq slineent(entget (ssname sliness count)))
(setq spntsl(cdr(assoc 10 slineent)))
(setq epntsl(cdr(assoc 11 slineent)))
(princ (strcat "\n第" (itoa(+ count 1)) "条直线的起点坐标为("))
(princ spntsl)
(princ "),终点坐标为(")
(princ epntsl)
(princ ")")
(setq count (+ count 1))
)
)
)
(entdel (car fline))
) |
|