你好。
有时,通过直接发布代码(当然是在代码标签之间,以避免众神和终结者的愤怒…)可以获得更多视图而不是附加它,强制用户登录以实际查看它。
因此,如果我理解正确的话,您试图实现的唯一一件事就是删除样条曲线,并最终得到最初由lisp进行的选择。由于在lisp中已经有一个包含样条曲线的var(e),只需添加我添加的绿色线,在选择并返回之前删除样条曲线,就可以轻松实现。那里不需要额外里程!
还有一点需要注意的是:一个lisp例程一旦执行,就会更改设置,而在最后又不恢复设置,这可能会让人恼火。最佳实践:查看并将其原始值存储在变量中,根据需要更改var,然后使用创建的变量中的原始值将其更改回来。(见添加的红色代码)。
- ;;; Make Lasso Selection (draw spline and Select Objects Within/Crossing it)
- ;;; Special thanks to Alan J. Thompson
- (defun c:SWC (/ _pac add ss i e temp it o a b pts tempC i3 ec)
- ;; Select Objects Within/Crossing Curve
- ;; Alan J. Thompson, 03.31.11
- ;; Slightly modified by Igal Averbuh 2017 (added option for splines)
- ;; Slightly modified by Jef! 2017 (erased spline + osmode restoration)
- (vl-load-com)
- (defun _pac (e / l v d lst)
- (setq d (- (setq v (/ (setq l (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) 100.))))
- (while (< (setq d (+ d v)) l)
- (setq lst (cons (vlax-curve-getPointAtDist e d) lst))
- )
- )
- (initget 0 "Crossing Within")
- (setq *SWC:Opt*
- (cond ((getkword (strcat "\nSpecify selection method witin curve [Crossing/Within] <"
- (cond (*SWC:Opt*)
- ((setq *SWC:Opt* "Crossing"))
- )
- ">: "
- )
- )
- )
- (*SWC:Opt*)
- )
- )
- (princ "\nSelect closed curves to select object(s) within: ")
- (if (setq add (ssadd)
- ss (ssget "L"
- )
- )
- (progn (repeat (setq i (sslength ss))
- (if (setq temp (ssget "_WP" (_pac (setq e (ssname ss (setq i (1- i)))))))
- (repeat (setq i2 (sslength temp)) (ssadd (ssname temp (setq i2 (1- i2))) add))
- )
- (if (eq *SWC:Opt* "Crossing")
- (progn (vla-getboundingbox (setq o (vlax-ename->vla-object e)) 'a 'b)
- (setq pts (mapcar 'vlax-safearray->list (list a b)))
- (if (setq tempC (ssget "_C"
- (list (caar pts) (cadar pts) 0.)
- (list (caadr pts) (cadadr pts) 0.)
- )
- )
- (repeat (setq i3 (sslength tempC))
- (if (vlax-invoke
- o
- 'Intersectwith
- (vlax-ename->vla-object (setq ec (ssname tempC (setq i3 (1- i3)))))
- acExtendNone
- )
- (ssadd ec add)
- )
- )
- )
- )
- )
- )
- [b][color=green](vla-delete (vlax-ename->vla-object e))[/color][/b]
- (sssetfirst nil add)
- (ssget "_I")
- )
- )
- (princ)
- )
- (defun C:LAT ( / [b][color=red]oldosmode[/color][/b] )
- [b][color=red](setq oldosmode (getvar 'osmode))[/color][/b]
- (setvar "osmode" 16384)
- (command "_.spline")
- (while (> (getvar "CmdActive") 0)
- (command pause)
- )
- (c:swc)
- [b][color=red](if oldosmode
- (setvar 'osmode oldosmode)
- )[/color][/b]
- (princ)
- )
干杯 |