AutoCAD

Full-Fillet Three Lines (AutoLISP Solutions Tutorial)

1 Nov, 2008 By: Tony Hotchkiss

This bit of code lets you automatically fillet three lines by simply selecting them in clockwise or counterclockwise order.


Bill Baker asked for a new way to fillet three lines in AutoCAD by picking them in clockwise or counterclockwise order. The result would be a full fillet in the sense that an arc would be constructed tangential to all three lines with a full trim.

Bill sent me a LISP routine that worked on old drawings but does not work in later versions of AutoCAD. The program was so old that it used no ActiveX Visual LISP methods, so I decided to ignore it and write a new program from scratch. It is usually easier to write new programs than to figure out how to fix old ones because programming techniques change quite often.

The AutoLISP Solution is FILLET-3-LINES.LSP, which allows the user to enter F3L on the Command line, then select each of the three lines in either clockwise or counterclockwise direction. The lines are then filleted automatically, and the fillets are placed on the same layer as the first selected line.

Get the Code!
Download the FILLET-3-LINES.LSP file from Cadalyst's CAD Tips site. Save the file in AutoCAD's Support directory. Use the Appload facility by selecting Tools / Load Application, then use the browser to select the FILLET-3-LINES.LSP file.

How to Use the FILLET-3-LINES.LSP Code
To start the program, enter F3L and you will be prompted to select the first line, then the middle line, and finally, the last line. Figure 1 shows sets of lines to be filleted, and Figure 2 shows the result of the fillets.

figure
Figure 1. Sets of three lines before filleting.

figure
Figure 2. Results of filleting.

After three lines have been selected, they are automatically filleted. The program can be restarted by simply hitting Enter, as is normal for repeating any AutoCAD command. If no lines are selected, an error message to that effect displays on the Command line.

Programming Notes
The program starts with my usual error handler and system variable manager. These functions are followed by FILLET-MAIN, which starts by defining the global variables *thisdrawing*, *modelspace*, and *utility*. The Visual LISP utility VLA-GETENTITY is used three times to create each of three line objects selected by the user. FILLET-MAIN proceeds to calculate the locations of the endpoints of two new lines, and the start, end, and an intermediate point of an arc. The new lines are created by successive calls to MAKE-NEW-LINE, and the arc is created by using the VL-CMDF command "ARC". My SETV and RSETV functions are used to place the new objects on the layer of the first line selected by the user. This code fragment is shown here:

(setv "CLAYER" lyr)
(make-new-line L1a P1 A1 1)
(make-new-line L3a P3 A3 2)
(vl-cmdf "ARC" P1 P2 P3)
(rsetv "CLAYER")

Note that the calls to MAKE-NEW-LINE have four arguments, the last of which is either 1 or 2. Those numbers are used to control the order of the start and endpoints of the lines using the logical IF function as follows:

(if (= num 1)
 (progn
  (setq start startpt)
  (setq end endpt)
 ) ;_ end of progn
 (progn
  (setq start endpt)
  (setq end startpt)
 ) ;_ end of progn
) ;_ end of if

MAKE-NEW-LINE uses the VLA-ADDLINE method to create new lines in model space.

As I was writing this column, I received an e-mail from a reader who wanted to use an earlier AutoLISP routine in which I had also created objects in model space. The reader wanted to modify that routine to create the objects in paper space instead of model space. In a future column I will add some code that gives a choice of model or paper space so the code can be inserted into any of my routines to make them more flexible.

In the meantime, I look forward to receiving your comments and requests for AutoLISP Solutions. Please contact me using the links below.


About the Author: Tony Hotchkiss


AutoCAD Tips!

Lynn Allen

Autodesk Technical Evangelist Lynn Allen guides you through a different AutoCAD feature in every edition of her popular "Circles and Lines" tutorial series. For even more AutoCAD how-to, check out Lynn's quick tips in the Cadalyst Video Gallery. Subscribe to Cadalyst's Tips & Tricks Tuesdays free e-newsletter and we'll notify you every time a new video tip is available. All exclusively from Cadalyst!
Follow Lynn on Twitter Follow Lynn on Twitter


Latest News from Cadalyst Partners
Feed
The Infinite Resource: the case for GMO instead of organic farming   22 May, 2013

I have no desire to eat pesticides. I really don't. Actually when I was a child growing up in New Orleans, a "fog truck" used to come down our...More>>Read more It's Alive in the Lab blog posts>>

Feed
TERA Semicon Drives Its Own Destiny with CAD and PDM   22 May, 2013

When you read the history of TERA Semicon, you can see right away that the company has had a strong vision and direction from Day 1. The South Korean...More>>Read more PTC Creo blog posts>>

Feed
Excel Hyperlinks & Document Management Tricks   22 May, 2013

Do you have to keep track of a lot of different folders and files? Do you wish you peers could open the correct Revit file? Are you tired of having...More>>Read more BIMbuilder blog posts>>

Feed
SolidWorks Simulation Tips: Parameters and Design Studies   22 May, 2013

In my opinion, one of the most underutilized tools in SolidWorks Simulation is the Design Study.  Design studies allow you to easily set up a...More>>Read more SolidWorks Blog posts>>

Feed
Is This the All-in-One Bike Helmet of the Future?   22 May, 2013

For those used to cycling on busy city streets (NYC comes to mind), the need for swift reaction times could be compared to that of catching a fly...More>>Read more SolidSmack blog posts>>

Poll
What type of input device (besides the keyboard) do you use at your primary CAD workstation?
Standard mouse
Trackball mouse
Programmable mouse
3D navigation device
Pen/tablet
Multiple devices
Submit Vote




Considering Wide Format Printing Solutions?
Four FREE White Papers Available:






Subscribe Cadalyst Newsletters