dexus Posted January 6, 2021 Posted January 6, 2021 (edited) I made a short function that extends a line with an arc tangent to the line you selected. The function works exactly the same as continuing a polyline only lets you select an object to start with. Anyway, I decided to share it, so here it is: ; Extend line with a line tangent to it - dexus (defun c:tan (/ ang obj obj-end obj-start pt select-data tanpt ~cmd *error*) (defun *error* (msg) (setvar "cmdecho" ~cmd) (princ msg) (princ) ) (setq ~cmd (getvar "cmdecho")) (setvar "cmdecho" 0) (while (not select-data) (setq select-data (entsel "\nSelect line to extend: ")) (if select-data (progn (setq obj (vlax-ename->vla-object (car select-data)) obj-start (vlax-curve-getstartpoint obj) obj-end (vlax-curve-getendpoint obj) pt (trans (cadr select-data) 1 0)) (if (< (distance obj-start pt) (distance obj-end pt)) (setq tanpt obj-start ang (angle '(0 0 0) (vlax-curve-getfirstderiv obj (vlax-curve-getparamatpoint obj tanpt)))) (setq tanpt obj-end ang (angle (vlax-curve-getfirstderiv obj (vlax-curve-getparamatpoint obj tanpt)) '(0 0 0))) ) (command "_.line" "_none" (polar tanpt ang 50.0) "_none" tanpt "" "_erase" "_l" "" "_.pline" "_none" tanpt "_arc" pause) ) (princ "\nNothing was selected, Please select a line!")) ) (setvar "CMDECHO" ~CMD) (princ) ) Hope this is useful to some of you. It was for me since I have to draw a lot of shapes that are tangent. Edited January 6, 2021 by dexus 2 Quote
BIGAL Posted January 7, 2021 Posted January 7, 2021 Post an image or a GIF so can see quickly what its doing. Quote
dan20047 Posted January 7, 2021 Posted January 7, 2021 Nice routine! Thanks for sharing. Saves some steps from my normal method to draw as pline > straight > then arc segment. made the attached animation using https://www.screentogif.com/ Quote
dexus Posted January 7, 2021 Author Posted January 7, 2021 Thanks Dan. I tried the screentogif program, works pretty well. Here is another gif which shows it also works on an arc. Quote
Grrr Posted January 9, 2021 Posted January 9, 2021 I like it, and its useful for me! Heres a little constructive note, if you don't mind - Replace the while block with and, and change the (setq select-data ...) : (while (not select-data) (setq select-data (entsel "\nSelect line to extend: ")) ; <Your code here> ); while with: (and (setq select-data ( (lambda ( / p r ) (setvar 'errno 0) (while (/= 52 (getvar 'errno)) (setq p (entsel "\nSelect line to extend <exit>: ")) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") (setvar 'errno 0) ) ( (not p) ) ( (setvar 'errno 52) (setq r p) ) ); cond ); while r ); lambda ) ); setq select-data ; <Your code here> ); and Quote
CADman916 Posted May 31 Posted May 31 This LISP routine is great - thanks for sharing! I was wondering if you can modify it to use a specific radius when extending from the line's endpoint instead of it being a random radius drawn tangent to the line? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.