• Home
  • Training Books
  • Subscribe to Our Email Newsletter
  • About
    • Contributors
    • Feedback
    • Contact
    • Privacy policy
    • Cookie Policy

CADnotes

CAD Tutorials and Best Practices for professionals and students

  • Featured
  • AutoCAD
    • AutoLISP
  • Revit
    • Revit Architecture Basic
    • Revit MEP Basic Tutorial
  • Inventor
  • MicroStation
    • MicroStation Basic Tutorial
You are here: Home / AutoCAD / Create a custom AutoCAD secondary command to work faster

Create a custom AutoCAD secondary command to work faster

September 30, 2015 by Edwin Prakoso 10 Comments

In this Article...

  • Secondary commands
    • O for OFFSET, OO for OFFSET to current layer
    • M for MOVE, MM for MOVE previous selected objects
  • Do you have an idea about other secondary commands?

Hai Le has shared some cool tips how to utilize macros in AutoCAD. He shows that customization doesn’t have to be complex.

Check some old tips he shared me before:

  1. Restore AutoCAD standard layers and styles.
  2. Automatic dimension spacing with double click.
  3. More macro tips to change UCS and text layer.

Macro is very useful, but you are limited to use it in CUI. You can access macro in toolbar, ribbon, double click or tool palettes. But if you want to use command line, then you have to use AutoLISP.

happy computer user

Just like macro, customization doesn’t have to be complex. Here are some secondary commands idea from Hai Le.

Secondary commands

AutoCAD commands have many settings that you can change in command line when the command is running. If you often change setting when you use a particular command, it would be a good idea to create a secondary command. Below are two ideas that you can use as secondary commands.

O for OFFSET, OO for OFFSET to current layer

By default AutoCAD Offset command will create a result on the same layer as original object. You can change the layer to current layer by changing the parameter when offset command active. It would be faster if you type OO to create the result on current layer, isn’t it?

You certainly can use OC as the command. But the idea of secondary commands here is to have options for available commands quickly. It’s much faster to type OO than OC, right?

Check this first AutoLISP tutorial: Zoom to origin. The tutorial will give you an idea how you can create simple customization by creating a LISP program.

Similar as described in that tutorial, you can create similar program to make Offset to current layer with this code:

(defun c:OO (/ )

(command "_OFFSET" "L" "C")

)

You can create another LISP to create object on the same layer as source object like this:

(defun c:OOO (/ )

(command "_OFFSET" "L" "S")

)

Of course, you can use other command than OOO if you like.

M for MOVE, MM for MOVE previous selected objects

Another idea is to create a custom command to move previously selected objects. Here is the code:

(defun c:MM (/ )

(command "_MOVE" "P")

)

Instead of typing M enter then P enter, you can type MM then enter.

You can download the LISP code above here. If you don’t know how to load AutoLISP program, read about it here.

Do you have an idea about other secondary commands?

If you like the idea of creating secondary commands, you may have some ideas to create a command that you use often. Do you have an idea to share with us? Write in this comment section so other readers can read about it too!

We surely can learn something from you too.

And thanks to Hai Le for the cool idea!

About Edwin Prakoso

I work as a Sr. Consultant in PT Cipta Satria Informatika. I've been using AutoCAD since R14 and Revit since Revit Building 9. I occasionally write for AUGIWorld magazine and I am also active in Autodesk discussion forum. I'm a member of Autodesk Expert Elite, an appreciation for individuals who give contributions to the Autodesk community.
Connect with me on twitter or LinkedIn.

Filed Under: AutoCAD, AutoLISP Tagged With: autocad tips, command line, settings

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

10 Comments
Inline Feedbacks
View all comments
Guy Goddard
Guy Goddard
9 years ago

I was in a business that had a lot of .25 radius fillets. a LISP line was created:

(defun c:F25 () (command “fillet” “r” “.25” “fillet”))

This would start the fillet command, set the radius to .25 and restart the fillet command to let you fillet what ever needs the fillet.

0
Reply
Edwin Prakoso
Edwin Prakoso
Author
Reply to  Guy Goddard
9 years ago

That is excellent Guy!
Thanks for sharing.

0
Reply
Rory Mackay
Rory Mackay
9 years ago

Hi there,
So I’ve just started looking into LISP and Macro’s and really don’t know much but I want to create the following command and I’m not finding the information I need :( (I’m not good with searches…)

The details of the command:
Once executed, the command opens a specific folder and presents the contents of the folder as options in the command line and as a dynamic menu.
On user selection, the folder is opened and the contents again displayed in the command line and as a dynamic.
This will continue until a dwg is selected at which point the command INSERTS the selected drawing.

The point of this is to increasing good old productivity.

Yes, I can easily set up a tool palette with all my blocks in and just drag and drop but there is more to this command, one step at a time though. First I need to write the script that will create the menu’s to get me to point of the block being inserted.

Do you know of any resources that can help?

0
Reply
Edwin Prakoso
Edwin Prakoso
Author
Reply to  Rory Mackay
9 years ago

Have you tried using Design Center? You can see the block thumbnail and insert it from any DWG file.
However, if you prefer to use LISP anyway, you can try to ask in CADtutor forum: http://www.cadtutor.net/forum/forum.php
There are many AutoLISP masters there who can you help you with it. My LISP knowledge is still basic, just for my own use.
I’m sorry I can’t be more helpful.

0
Reply
Rory Mackay
Rory Mackay
Reply to  Edwin Prakoso
9 years ago

Hi Edwin,
Thanks for the reply. I do already use design center but my end purpose is to create tool that inserts a block selected by the user and then performs a single row array in ‘x’ with a user specified number of columns and the blocks touching end to end.

It may well be that I need to use VisualLISP or something else, LISP is just where I have started

I’ve written V.1 of the array part of this tool (see below) which cuts down on data entry as it auto fills all the information regarding rows. The main improvement I want to achieve in this routine is to have the routine work out the column width from the block as this removes another user input point leaving the only user inputs being to select the block and enter the quantity of columns required.

I’ll check out the site you have suggested, hopefully I’ll find something there.

Here’s my little array command:

(defun c:xarray()
(setq oldsnap (getvar “osmode”))
(setvar “osmode” 1)
; this is to make selecting the ends of the block easier without the user
;having to change their snap settings
(command “array” pause “” “rectangular” “1” pause pause “”)
(setvar “osmode” oldsnap)
; this returns the snaps to the users previous settings
(princ)
)
(princ)

0
Reply
Francisco J. Casanova
Francisco J. Casanova
9 years ago

Wow! I am definitly not to where i would try this, yet. I will be soon, I just need the enviornment and mind syncronicity.

0
Reply
Edmar Elcarte
Edmar Elcarte
9 years ago

Hey Edwin,

I had started a new job I had been a long time AutoCad user since 2003 but had stopped using it on 2010. The problem is the job I have me will require me to use autocad and revit and ai had found this website which is really helpful.

I know you are busy but I hope you would be able to help me go back to the proficent level and I am anout to embark a new learning progress with Revit.

Can sou help me what to do?

0
Reply
E.F. Lucas
E.F. Lucas
9 years ago

I made en lisp to move multiple times te same selection.

;;;Move Multiple
(defun c:MMultiple (/ ss1 L1 L2)
(setq ss1 (ssget))
(while (setq L1 (getpoint “\nBasepoint (1): “))
(setq L2 (getpoint L1 “\nReferencepoint (2): “))
(command “MOVE” ss1 “” L1 L2)
) ;_ end of while
(princ)
) ;_ end of defun

0
Reply
Edwin Prakoso
Edwin Prakoso
Author
Reply to  E.F. Lucas
9 years ago

That is cool!
Thanks for sharing.

0
Reply
George
George
9 years ago

I am hoping that you could help figure out a macro to add to current autocad commands to force object to a specific layer and return to previous layer, aca 2016

0
Reply
wpdiscuz   wpDiscuz

Featured

8 Frequent Issues when installing Autodesk Products

Many times the installation failed. We need to know what the problem is and what the workaround is. If you don’t know what’s the problem, you may not be able to install it even you have tried several times. Let’s try to fix it!

Recent Articles

  • Autodesk Construction Cloud Activity Log
  • Exporting AutoCAD Plant 3D Model to Navisworks
  • Autodesk Data Connector for Power BI is Now Available

Advertisement

New on CADnotes

  • Autodesk Construction Cloud Activity Log
  • Exporting AutoCAD Plant 3D Model to Navisworks
  • Autodesk Data Connector for Power BI is Now Available
  • Autodesk Forma Design Contest
  • Revit 2025: Toposolid Enhancements

Meet the Authors

avatar for
avatar for
avatar for
avatar for
avatar for
avatar for

Get Connected

CADnotes on FacebookCADnotes on InstagramCADnotes on TwitterCADnotes on YouTube

© 2009 – 2025 CADnotes · Feedback · Privacy Policy · Become an affiliate

wpDiscuz