Categories

AutoCAD 2015 and AutoCAD LT 2015 Bible

The most comprehensive AutoCAD book around!

Reduce mouse-clicks and increase productivity using AutoLISP

This is a guest post by Sanjay Kulkarni, an AutoCAD programmer. You can read more about him at the end of this post.

The number of mouse-clicks required to perform a task is generally a good indicator of productivity. The fewer the number of clicks, the less time required–hence more productivity.

In this post we will see an example of reducing the number of mouse-clicks, and thus improving productivity, using AutoLISP. We will use the example of the FILLET command.

Thanks to one of the blog readers Bruce Newman, who sent a problem to me. It was the source for this post.

The most simple situation where you create a fillet is when two perpendicular lines meet. Inside the FILLET command, you select the two lines (requiring 2 clicks) and AutoCAD creates the fillet.

Reducing clicks and increasing productivity in AutoCAD with AutoLISP

 

The equivalent AutoLISP code would be

(command “fillet” (car (entsel “\nSelect the first line: “))(entsel “\nSelect the second line: “)))

This still requires two clicks.

So, the problem now reduces to finding a method to select two lines with a single click.

Before trying in AutoLISP, let’s find out if we can do it manually. There seems to be no option or a work-around to do what we want.

Luckily, we have a single point (the intersection) that is common to both lines. So, let’s explore if we can somehow use the intersection point to select the 2 lines. If you have to click only one point to select multiple objects, obviously it should be the intersection point.

Study of selection methods shows that there are two options that base their selection on two points: crossing & window. Since W must include the objects fully, it won’t be suitable. So let’s try C option.

Use the SELECT command and then the c option and click on the intersection point in response to both points. AND …….. Both lines are selected!

The equivalent AutoLISP code would be

(setq ssLines (ssget “c” (setq pt1 (getpoint “\nSelect Intersection: “) ) pt1))

Now I can use each line to create a fillet.

(command “fillet” (ssname ssLines 0) (ssname ssLines 1))

And yes … the fillet appears!

Reducing clicks and increasing productivity in AutoCAD using AutoLISP

 

So, here is my simple program:

(defun c:FiletByPt ()

;;; creates fillet by single click

;;; ssk 110918

(setq ssLines (ssget “c” (setq pt1 (getpoint “\nSelect Intersection: “) ) pt1))

(command “fillet” (ssname ssLines 0) (ssname ssLines 1))

)

(prompt “\nCreates a fillet by single click. Type ‘FiletByPt'”)

Note: In the command name above, FiletByPt, “fillet” is intentionally spelled “filet” to avoid confusion as you start to type the custom AutoLISP command.

To use the above code, copy and paste it into Notepad and save it as filetbypt.lsp in a location that is in AutoCAD’s support file search path. Instructions for loading the program are here.

However life is always not so simple. The lines may extend beyond the intersection point. My R&D shows that the above code still works as shown in Fig. 3.

AutoCAD tip: Reduce clicks and increase productivity in AutoCAD with AutoLISP

It even works when the two lines are not perpendicular.

When two lines are selected using a single point, AutoCAD finds and trims shorter segments of each line and then creates a fillet between the two remaining segments.

There might be situations (when two lines meet at the midpoint) where the code may not work or possibly needs modification.

But, if creating fillets is a major task for you, and saving 50% of time can result in significant gain, go ahead and use this code.

Are you stuck-up with such trivial tasks that are strain on your resources? Let me know and we’ll see if I can help you with useful hints or sample code.

Sanjay Kulkarni is an experienced CAD (AutoCAD, Inventor, SolidEdge, CATIA, NX) programmer and a member of the Autodesk Developer Network. He is fluent in AutoLISP, VBA, and VB.NET. He has written for AugiWORLD and Inside AutoCAD. He can be contacted at sanganaksakha@gmail.com

 

Ellen Finkelstein

18 comments to Reduce mouse-clicks and increase productivity using AutoLISP

  • Jarred

    Can this be used on earlier versions of AutoCAD? Say like back to 2006?

  • Edgetrimmer

    Very interesting! I appreciate the “shout-out”. Always easier to ask than to answer questions though. I’m looking into utilizing the cool single click fillet.

    Bruce

  • Edgetrimmer

    It occured to me that by renaming the function from c:FiletByPoint in your code above to something like c:ChamByPt and changing the “._fillet” command to “._chamfer”, you also have just created a single click chamfer command.

  • neil jones

    Doesn’t work for me….!!!!!

    Command: FILETBYPT
    ; error: too many arguments

  • Sanjay Kulkarni

    Jarred,

    Thanks for your comment.

    I don’t see any problem in this code working in any version. As far as I remember, fillet command has not changed for many versions. So, go ahead and use it in any version.

    Let me know if you encounter any problems.

    – Sanjay Kulkarni

  • Sanjay Kulkarni

    Edgetrimmer,

    Thank you for your comments.

    Please do utilize this single click fillet tool.

    You are right. By renaming the function from c:FiletByPoint to c:ChamByPt and changing the “._fillet” command to “._chamfer”, will create a single click chamfer command. Please go ahead, create and use it. Contact me if you encounter any difficulties.

    And may be there might be few more such possibilities.

    – Sanjay Kulkarni

  • Sanjay Kulkarni

    neil jones,

    Thank you for posting your problem.

    I can’t imagine a situation where this error could be generated by the code.

    I’ll test it more and see if I can reproduce the error.

    Meanwhile, can you copy and paste the code again. I think you may have missed something while copying the code.

    If it still does not work, please send me the minimal drawing that you are working on and I will try out on that.

    – Sanjay Kulkarni

  • bart

    I tried it and get error message “too many arguments”

  • Sanjay Kulkarni

    bart,

    Can you send me the drawing that you are working on. Keep it small. Include only relevant geometry.

    After trying out, I will let you know what is happening.

    – Sanjay Kulkarni

  • AutoCAD Blog Round-Up | CAD/CAM Performance Blog

    […] Reduce mouse-clicks and increase productivity using AutoLISP Originally Posted by Sanjay Kulkarni, an AutoCAD programmer The number of mouse-clicks required to perform a task is generally a good indicator of productivity. The fewer the number of clicks, the less time required–hence more productivity. Read Full Post […]

  • Mike

    Doesnt really matter, windows and autocad keep exrapolating the menus and commands inwards so it takes an extra 2 clicks where it used to be apparent.
    The other time waster is the x close box – is it on the left or the right.

  • Edgetrimmer

    If the filetbypt.lsp code isn’t working for you, try changing the (command “fillet” …) to (command “._fillet” …). It didn’t work for me until I made that minor change.

  • Edgetrimmer

    Caution: I may have the order of the “_” and the “.” wrong in “._fillet” of my above suggestion. Maybe it doesn’t matter. Anyone know?

  • jdavis417

    Just a quick reminder…
    LISP can call on any of your “loaded” Action Recording macros!
    Script Pro (a free download from Autodesk site), Standards, LISP & Action Recordings helped me to bring tens-of-thousands of legacy drawings into compliance in my last position!

    I’ve been using Inventor for a year or more so it’s not very fresh in my memory… but I swear these are powerful solutions for those of us who don’t know or have time for .NET solutions.

  • Pither

    Why can’t pick end point, only intersection point. The routine result nil.

  • Pither

    Hi Neil Jones,
    Please change “” sign that you copy from text above.
    You can check its mistake in visual lisp editor.

    Good luck.

  • Nitin

    Hi sanjay,

    I was trying to use your lsp code but I am noe able to use. I have AutoCad2009. Can u please email lsp file to my specified mail ID.

  • Richard

    I have a Logitech M705 mouse. I have been using this model for about 8 years. Up until I changed to AutoCAD Arch. 2012 I was able to program the buttons on the mouse to specific functions or keystrokes. In 2012 this does not work. I have tried assigning these functions in the CUI to no success. Uninstalling mouse software reinstalling as Administrator and no success. I have searched many AutoCAD blogs no success. Do you know of any fixes or options. Button #3 – middle Button, button #4,#5 – Escape and #8- shift. Hope you can help. I would like to reduce mouse clicks but I have to get them to work first.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>