I've wanted something similar in the past, so I figured I'd have a go at it. This is my first attempt at using the ActiveX interface, so some things might have been accomplished more easily in another way, but this works.
It lets you select a set of objects (any drawing objects should work, although results are unpredictable for circles). Any objects that intersect two and only two of the other objects in the selection set will be broken between the intersection points. If a given object has more than two intersections, then the code wouldn't know which segments to remove. It would need to be extended to allow the user to specify which segments to remove, possibly by selecting inside the desired intersections as you proposed, although I haven't yet figured out the best way of going about it. Feel free to tackle it yourself.
The code loops until you hit enter or right-click without selecting any objects.
Code:
;; takes a selection set, and trims the gap between intersection points for
;; all objects that intersect two and only two of the other objects in the set
;; Richard Sincovec, July 11 2004
(vl-load-com)
(defun c:itrim (/ acadObj doc ssets ss count err i j items item intxlist
intitem)
(setq acadObj (vlax-get-acad-object)
doc (vla-get-activeDocument acadObj)
ssets (vla-get-selectionSets doc)
)
(setq err (vl-catch-all-apply
(function
(lambda ()
(setq ss (vla-add ssets "ZYZ_ITRIM"))
) ;lambda
) ;function
) ;vl-catch-all-apply
) ;setq
(if (vl-catch-all-error-p err)
;; error is probably "ss already exists"
;; it shouldn't yet, but use it if it does
(setq ss (vla-item ssets "ZYZ_ITRIM"))
) ;if
(while ; (MAIN)
(progn
(vla-clear ss)
(vla-selectOnScreen ss)
(setq count (vla-get-count ss))
(/= count 0)
) ;progn
(setq i count
items nil
) ;setq
(while (/= i 0)
(setq i (1- i)
item (vla-item ss i)
j count
intxlist nil
) ;setq
(while (/= j 0)
(setq j (1- j)
intitem (vla-item ss j)
) ;setq
;; I kept getting an exception on vlax-safearray->list
;; if intersectWith found no points, and couldn't figure
;; out offhand how to stop getting it, so I decided to catch
;; and ignore it instead
(if (/= (vla-get-handle item) (vla-get-handle intitem))
(vl-catch-all-apply
(function
(lambda ()
(setq
intx (vlax-safearray->list
(vlax-variant-value
(vla-IntersectWith
item
intitem
acExtendNone
)
)
)
intxlist (append intxlist (list intx))
) ;setq
) ;lambda
) ;function
) ;vl-catch-all-apply
) ;if
) ;while j
;; if we found two and only two intersections, store the entity for breaking
;; if we break it now, it will confuse the rest of the intersection checking
(if (= (length intxlist) 2)
(setq
items (append
items
(list (cons (vlax-vla-object->ename item) intxlist))
)
)
) ;if
) ;while i
;; break the items
(foreach item items
(command "break"
(list (car item) (cadr item))
(caddr item)
)
) ;foreach
) ;while (MAIN)
(vla-delete ss)
(princ)
) ;defun