I'm working on a routine to trim intersections of lines or other objects. The steps are (1) select a line, arc, ellipse, etc., (2) offest the selection on both sides, (3) retrieve the offset entities, and (4) pass these entities to the TRIM command as the "trim to" entities. I can then select any intersecting entities that I want to trim out. I have it working for all but a special case for ellipses. If the ellipse is long and narrow there can be a situation where it offset on the inside is actually two splines rather than one, and I can't figure out a way to access both interior splines. I know a bit about "old fashioned" autolisp, but very little about vla/vlax.
Here's work in progress. Bits and pices borrowed from many places...
(defun C:eb ( / )
(defun initerr ()
(setq temperr *error*)
(setq *error* trap)
(princ)
)
(defun trap (errmsg)
(command)
(if (not (member errmsg '("Cannot offset that object")))
(princ (strcat "\nError: " errmsg))
)
(setq *error* temperr)
(princ)
)
(defun dxf (1code 1ent) (cdr (assoc 1code 1ent)))
(defun OffsetDouble (ename dist / vobj enew)
(setq enew nil)
(setq vobj (vlax-ename->vla-object ename))
(if (vlax-method-applicable-p vobj 'Offset)
(progn
(setq tmplst nil)
(vl-catch-all-error-p
(setq TmpLst (vl-catch-all-apply 'vlax-invoke (list vobj 'Offset dist)))
)
(if (= (type tmplst) 'LIST)
(progn
(setq enew (entlast))
)
)
(setq tmplst nil)
(vl-catch-all-error-p
(setq TmpLst (vl-catch-all-apply 'vlax-invoke (list vobj 'Offset (- dist))))
)
(if (= (type tmplst) 'LIST)
(progn
(if (= enew nil)
(setq enew (entlast))
(setq enew (list (entlast) enew))
)
)
)
)
)
enew
)
;; function starts here
(initerr)
(setvar "cmdecho" 0)
(command "._undo" "end")
(command "._undo" "begin")
(setq offset_dist (* (getvar "dimscale") 0.09375))
(setq cutline_select (entsel "\nSelect entity to trim around: "))
(setq cutline_pt (osnap (cadr cutline_select) "near"))
(setq cutline (entget (car cutline_select)))
(setq offset_ok (offsetdouble (dxf -1 cutline) offset_dist))
(print offset_ok)
(princ)
)
I've also tried using variations of:
(setq enew (vlax-vla-object->ename (car tmplst)))
but everything I've tried has returned only one of the two interior splines.
Any help on how to get enames for both splines would be appreciated, as would any other suggestions.
Martin
a
<edit> code tags added by CAB