这是一个非常实用的小工具,框选断开插件,在晓东上找的,很好用。
有一个地方要改一下,就是如何加一语句,实现不用选择物体,省去这一步。输入命令后,框选哪,就断开哪。哪位高手给修改一下。
- (defun c:y (/ e p1 p2 pts pl ptl ss pt el)
- (if (and (setq e (xdrx_entsel
- "\n请选择要断开的曲线: "
- '((0 . "*line,arc,circle,ellipse"))
- )
- )
- (setvar "osmode" 0)
- (progn (redraw (car e) 3) t)
- (setq p1 (getpoint "\n起点: "))
- (setq p2 (getcorner p1 "\n终点: "))
- )
- (progn
- (setq pts (list p1
- (list (car p1) (cadr p2) 0.)
- p2
- (list (car p2) (cadr p1) 0.)
- )
- pl (apply 'xdrx_polyline_make (append pts '(t)))
- ptl (vl-sort (xdrx_entity_intersectwith (car e) pl)
- '(lambda (p1 p2)
- (< (xdrx_curve_getparamatpoint (car e) p1)
- (xdrx_curve_getparamatpoint (car e) p2)
- )
- )
- )
- )
- (xdrx_setmark)
- (apply 'xdrx_curve_break (cons (car e) ptl))
- (setq ss (xdrx_getss)
- el (xdrx_pickset->ents ss)
- )
- (if (xdrx_point_isinside
- (cadr (xdrx_curve_getpoint (car e)))
- pl
- )
- (progn
- (xdrx_object_swapid pt (car e))
- (xdrx_entity_delete (car e))
- )
- (foreach x el
- (if (xdrx_point_isinside
- (cadr (xdrx_curve_getpoint x))
- pl
- )
- (xdrx_entity_delete x)
- )
- )
- )
- (xdrx_entity_delete pl)
- )
- )
- (princ)
- )
|