After seeing a breaking routine in another thread, I thought I would take a crack at making one that I have needed for sometime now. Basically I need it to break the specified object at the intersection of selected objects.
This is what I have come up with:
;Written by: Chris Wade
;2010-02-03
;Breaks objects at intersections
(defun c:BreakInt (/ Ent1 Ent1E EntSS ct IntLst ct2 pt1 pt1a bptlist BDis ct3)
(if (or (/= (getvar "cvport") 1) (/= (getvar "tilemode") 0))
(setq BDis (/ 0.1 (getvar "cannoscalevalue")))
(setq BDis 0.1)
)
(princ "\n")
(while (= Ent1 nil)
(setq Ent1 (entsel "\rSelect the object to break: "))
)
(setq Ent1E (vlax-ename->vla-object (car Ent1)))
(princ "\n")
(while (= EntSS nil)
(princ "\rSelect the objects to break with: ")
(setq EntSS (ssget))
)
(setq ct 0)
(while (< ct (sslength EntSS))
(setq intLst (vlax-invoke Ent1E 'intersectWith (vlax-ename->vla-object (ssname EntSS ct)) acExtendNone))
(cond
((/= intLst nil)
(setq ct2 0)
(while (< ct2 (length intLst))
(setq pt1 (list (nth ct2 intLst) (nth (+ ct2 1) intLst) (nth (+ ct2 2) intLst)))
(setq pt1a (vlax-curve-getdistatparam Ent1E (vlax-curve-getparamatpoint Ent1E pt1)))
(cond
((= bptlist nil)
(setq bptlist (list (vlax-curve-getpointatdist Ent1E (- pt1a BDis))))
)
(T
(setq bptlist (append bptlist (list (vlax-curve-getpointatdist Ent1E (- pt1a BDis)))))
)
)
(setq bptlist (append bptlist (list (vlax-curve-getpointatdist Ent1E (+ pt1a BDis)))))
(setq ct2 (+ ct2 3))
)
)
)
(setq ct (+ ct 1))
)
(cond
((/= bptlist nil)
(setq ct3 0)
(while (< ct3 (length bptlist))
(command "._break" "_non" (trans (nth ct3 bptlist) 0 1) "_non" (trans (nth (+ ct3 1) bptlist) 0 1))
(setq ct3 (+ ct3 2))
)
)
)
)
(defun C:BI ()
(c:breakint)
)
It definitely works, but I am wondering if anyone has better ways to accomplish this? I want to get better with my LISP routines.