@mrsmithTYTMZ wrote:
I am new to AutoLISP so please bare with me. I have to create a .001" break in either the middle of a line or at a specified pick point. ....
[Do I have to take my clothes off? (The word you want is "bear with me.")]
How about some that are not restricted to Line objects? The following Gap001M [for a Gap of .001 at the Midpoint] and Gap001S [for the gap at the Selection point] will do it to Lines, Arcs, Circles, Polylines [any variety, at line or arc segments], Ellipses, Splines, and [in only the at-the-selection-point one] Xlines and Rays.
It could still use the usual enhancements [error handler, Undo begin/end wrapping, etc.], but see what you think.
If you use Gap001M on a Polyline, it puts the gap in the middle of its overall length, but it could be altered to do it at the middle of the segment in which you pick it, if desired. It could also be altered to ask for a Gap size, including a default, so you wouldn't need separate ones for different sizes. And it could be altered to operate repeatedly as long as continue to pick objects, and/or for Gap001M, to let you select as many objects as you want all at once.
(vl-load-com)
(defun GetForGap (subpr / edata etype)
(and
(setq esel (entsel (strcat "\nSelect object to make gap at " subpr "point: ")))
(setq ent (car esel) edata (entget ent) etype (cdr (assoc 0 edata)))
(wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE,RAY")
(/= etype "MLINE"); accepted by above, but not by (vlax-curve...)
(if (= subpr "mid") (not (wcmatch etype "XLINE,RAY")) T)
; allow only in Gap001S [can't calculate midpoint]
(= (logand (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 edata))))) 4) 0); unlocked
); and
); defun -- GetForGap
(defun Gap001 (loc / osm cir)
(setq osm (getvar 'osmode))
(setvar 'osmode 0)
(command
"_.circle" loc 0.0005
"_.zoom" (polar loc 0 0.001) (polar loc pi 0.001)
"_.regen" ; [because Trim pick at 'loc' can miss if curve is segmented]
"_.trim" (setq cir (entlast)) "" loc ""
"_.erase" cir ""
"_.zoom" "_previous"
); command
(setvar 'osmode osm)
); defun -- Gap001
(defun C:Gap001M (/ esel ent)
(if (GetForGap "mid")
(Gap001 ; then
(vlax-curve-getPointAtDist ent
(/ (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)) 2)
); ...getPoint...
); Gap001
(prompt "\nNothing selected, not a viable object, or on a locked Layer."); else
); if
(princ)
); defun -- C:Gap001M
(defun C:Gap001S (/ esel ent)
(if (GetForGap "selection ")
(Gap001 (osnap (cadr esel) "_nea")); then
(prompt "\nNothing selected, not a viable object, or on a locked Layer."); else
); if
(princ)
); defun -- C:Gap001S
Kent Cooper, AIA