AutoLISP: Arc Tangent to Line

I know that this blog has a lot of AutoLISP code on it. I will focus on regular drafting topics soon. It’s just that I have recently needed these LISP routines and thought that if they were handy for me, they would also be handy for you as well. Here is another LISP routine to add to your collection…

Without using a LISP routine, you can create an arc that is tangent to the last drawn line/arc by using the “Continue” option of the arc command (as seen below).

Also in AutoCAD 2012 there is the new BLEND command which will do pretty much the same thing as the LISP routine with the exception that with the BLEND tool, you have to pick two objects in order for it to work. This lisp routine simply asks you to select an existing line or arc and it starts a tangent arc from the end closest to where you pick. and you are able to either pick another line/arc or click anywhere you choose which is really helpful.

Here’s how:

  • ARCTAN <enter> to start
  • Specify the object that the arc is to be tangent to.
  • Specify the end point on the selected object to be the start point or the arc
  • Specify the end point of the arc
  • Prompt: “Is arc oriented correctly?” Y = will keep the arc the way it is. N = will flip the arc as seen on the single line in the animation.
FYI – I show in the below animation how the Blend tool makes a spline that is more like an ellipse than a circle. This LISP routine can be used sort of like the blend tool to create an arc.

~enjoy

;;; CADALYST 05/08 www.cadalyst.com/code

;;; Tip 2290: Arctan.LSP Tangent Arc Generators, File 1 of 5 (c) 2008 Rogelio Bravo

;;; Modified BY Greg Battin for english use

;;;

;; ARCTAN draws an arc tangent to any kind of object

;; picking any other point as end point of arc

;; written by Rogelio Bravo, Spain

(defun C:arctan ()

(graphscr)

(vl-load-com)

(setq obj (car (entsel "\nPick base entity for arc:")))

(setq ref (getvar "osmode"));

(command "_osnap" "_end,_nea");

(setq ptan (getpoint "\nSpecify start point of arc:"))

(setvar "osmode" ref);

(setq pam (vlax-curve-getParamAtPoint obj ptan))

(setq vtr (vlax-curve-getFirstDeriv obj pam));;

(setq ang (angle '(0 0 0) vtr));

;;(setq ref (getvar "osmode"));

;;(command "_osnap" "_end,_nea");

;;(setvar "osmode" ref);

(setq pt4 (getpoint "\nSpecify end point of arc: "))

(command "_arc" ptan "_e" pt4 "_d" (/ (* 180.0 ang) pi))

(initget 6 "Y N")

(if (null (setq resp (getkword "\nIs arc oriented correctly? (Y/N)<Y>:" )))

(setq resp "Y")

)

(while (/= resp "Y")

(setq ang (+ ang pi))

(command "_erase" "_l" "")

(command "_arc" ptan "_e" pt4 "_d" (/ (* 180.0 ang) pi))

(initget 6 "Si No")

(if (null (setq resp (getkword "\nIs arc oriented correctly? (Y/N)<Y>:" )))

(setq resp "Y")

)

);end while

)
Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Modifying, TIPS, Uncategorized. Bookmark the permalink.

One Response to AutoLISP: Arc Tangent to Line

  1. Pingback: New in 2012: Blend Command | AutoCAD Tips

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s