@andrew_k wrote:
....
I am looking to allow lines to be converted as well, and not just polylines. I also wanted control over the arc length and the exact intersection where the arc is being placed ....
Something like this? [Untested -- I left much of your code alone]
(defun c:LineJump (/ a d e etype i o p p1 p2) ;; Adds a 'hop' to a LWPolyline or Line
(setq a (getdist "\nSpecify arc length: "))
(setvar 'peditaccept 1); [for PEDIT - could save current value and reset later if desired]
(while
(and
(setq e (entsel "\nPick a line or polyline to add a hop: "))
(wcmatch (setq etype (cdr (assoc 0 (entget (car e))))) "LINE,LWPOLYLINE")
); and
(if (= etype "LINE") (command "_.pedit" (car e) "")); convert Line to Polyline
(setq p (getpoint "\nSpecify intersection: "))
(setq i (1+ (fix (vlax-curve-getparamatpoint (setq e (car e)) p))))
(setq d (vlax-curve-getdistatpoint e p))
(setq p1 (vlax-curve-getpointatdist e (+ d a)))
(setq p2 (vlax-curve-getpointatdist e (- d a)))
(setq o (vlax-ename->vla-object e)); make into VLA object for next functions:
(vlax-invoke o 'addvertex i (mapcar '+ p1 '(0 0)))
(vlax-invoke o 'addvertex i (mapcar '+ p2 '(0 0)))
(vla-setbulge ; make into half-circle arc segment
o
i
(cond
((< (angle '(0 0) p1) (angle '(0 0) p2)) -1.)
(1.)
); cond
); vla-setbulge
); while
(princ)
)
(vl-load-com)
Enter at the pick-one prompt will end it.
A couple of explanations too long for inside the code window:
The (mapcar '+ {point variable} '(0 0)) parts make a 3-coordinate XYZ point list into a 2-coordinate XY-only list, which it will want for adding a vertex to a LWPolyline. [Read about (mapcar) in Help to understand why.]
The bulge factor of an arc segment is 1 for a half-circle arc, positive for CCW direction and negative for CW direction.
Kent Cooper, AIA