修改第二个代码。。。虽然以不寻常的方式使用(vl-some)在“ssget”中具有创造性,但我认为这是不必要的和过度编程的情况。。。正如你们所见,我已经更改了前一篇文章中的两个代码,现在所有4个代码都兼容,可以顺序使用之前的输入-用户应该寻找的唯一一件事是在任务完成后将全局*n*变量置零。。。
- ; Trim Curves - Both ends
- (defun C:trimcurves ( / n Lst2 r )
- (vl-load-com)
- (or *n* (setq *n* 1.0))
- (initget (+ 2 4))
- (setq n (getdist (strcat "\nPick or specify trim value <" (rtos *n* 2 20) "> : ")))
- (if (null n)
- (setq n *n*)
- (setq *n* n)
- )
- (while
- (and
- (princ "\nSelect curves to trim <exit> : ")
- (ssget "_:L-I" '((0 . "*POLYLINE,SPLINE,LINE,HELIX,ARC,ELLIPSE")))
- )
- (progn
- (
- (lambda ( SS / Lst )
- (if SS
- (progn
- (vlax-map-collection SS (function (lambda ( o ) (setq Lst (cons (vlax-vla-object->ename o) Lst)))))
- (mapcar
- (function
- (lambda ( e / spt ept )
- (if
- (and
- (not
- (or
- (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getEndParam (list e)))
- (vlax-curve-isClosed e)
- (< (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)) n)
- )
- )
- (setq spt (vlax-curve-getStartPoint e))
- (setq ept (vlax-curve-getEndPoint e))
- )
- (setq Lst2 (cons (list e spt ept) Lst2))
- )
- )
- )
- Lst
- )
- )
- )
- (vla-Delete SS)
- )
- (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))
- )
- (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
- (vla-ZoomExtents (vlax-get-acad-object))
- (foreach x Lst2
- (and
- (not (vl-catch-all-error-p (setq r (vl-catch-all-apply 'vlax-curve-getDistAtPoint (list (car x) (caddr x))))))
- r
- (command "_.BREAK" (nentselp (caddr x)) "_non" (trans (vlax-curve-getPointAtDist (car x) (- r n)) 0 1) )
- )
- (and
- (not (vl-catch-all-error-p (setq r (vl-catch-all-apply 'vlax-curve-getDistAtPoint (list (car x) (cadr x))))))
- r
- (command "_.BREAK" (nentselp (cadr x)) "_non" (trans (vlax-curve-getPointAtDist (car x) (+ r n)) 0 1) )
- )
- )
- (vla-ZoomPrevious (vlax-get-acad-object))
- (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
- )
- )
- (princ)
- )
尊敬的M.R。
P、 我不知道你想说什么关于PLINETOOLS-他们在我看来正确地填补了所有Lisp程序,它应该有。。。此处发布的Lisp是独立的,可能适用于也可能不适用于多段线实体,因此PLINETOOLS是独立的。。。 |