Tutorial - Create A Custom Command - AutoCAD Tips Blog
Tutorial - Create A Custom Command - AutoCAD Tips Blog
com/tutorial-create-a-custom-command/
« Tutorial: Create a custom workspace in AutoCAD 2006 How to stay up to date with AutoCAD
and later
If you find yourself using the same combination of commands and options over and over, you can easily create a custom
command that executes the combination with a click of a button or a menu item. In this tutorial, I explain the basics of
AutoCAD’s menu syntax so that you can create your own commands. No programming required!
1. Enter cui at the command line/dynamic tooltip to open the Customize User Interface dialog box.
2. In the Command List pane, click New (Create a New Command).
3. In the Properties pane, enter a name for the command in the Name text box. Also enter a description in the Description
text box.
4. If you think your command will be long or need more than one line, click in the Macro text box and then click the Ellipsis
button that appears on the right. Then enter your macro in the Long String Editor dialog box. Otherwise, enter the
macro in the Macro text box. Start by writing out the combination of commands and options as you would enter them on
the command line or in a script. Then add any necessary special characters.
Below are the special characters you need to know for menu macros:
Character Description
Equivalent to pressing Enter except when entering
text to create a text object that contains spaces
Space
(between words). Use between the command and its
options.
Equivalent to pressing Enter. The end of a line in a
menu macro is also equivalent to pressing Enter.
More helpful than using a space when you need to
; (semi-colon)
press Enter twice, because it shows the number of
Enters more clearly. Also helpful at the end of the
macro.
Pauses for user input, such as picking a point or
\
entering a value.
At the end of a macro line, continues the macro to the
+
next line
At the beginning of a macro, before ^C^C, repeats the
* macro until you press Esc or choose another menu
item.
Toggles the display of the menu macro on the
^P command line; makes the macro look neater when
you use it.
1 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
1. From the Command List Categories drop-down list, choose Custom Commands to easily find your command. Select it
and drag it to the desired menu or toolbar at the top of the Customize User Interface dialog box.
2. If you drag it to a toolbar, use the Button Editor to give it an image. Usually, you choose an existing button to start with,
click Edit, and modify it. Then click the Save As button to save the icon image.
3. Click OK and try out your new command!
Top Customization Tips Insert data from an Excel AutoCAD Bible AutoCAD Tutorial: Create
Every AutoCAD User worksheet Companion Website a rectangle with an
Should Know - Here’s adjustable corner
your ebook
Tutorial: Automate tasks Test Page Add a solid fill to a closed AutoCAD 2015 &
2 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
Adel Moldovan
July 30, 2011 at 4:44 am
Hi,
How can I change the default behavior of Multiple Object Stretch command?
Meaning:
when I press the MOS command and hit enter or right click mouse button it executes defaults Crossing Window selection,
but wish to go for a Crossing Polygon option. It’s annoying to keep entering CP or press down arrow keyboard button to
select it over and over again since the CP option is the option I use most of the time.
It’s Acad 2012
Thx.
Ellen
July 30, 2011 at 11:25 am
Are you just talking about the STRETCH command? I’ve never heard the phrase “Multiple Object Stretch,”
although of course, you can stretch multiple objects with the STRETCH command.
I would simply create a custom command and assign it to a keyboard shortcut or add it as a button to a ribbon panel. I
have instructions here: https://allaboutcad.com/tutorial-create-a-custom-command/. This might also help —
https://allaboutcad.com/create-a-custom-toolbar-in-autocad-2006-or-later/ — although it describes adding a button to
a toolbar, rather than to the ribbon.
Adel Moldovan
July 31, 2011 at 3:45 am
Dear Ellen,
Thank for your quick replay.
Yes, I meant the STRETCH command. “Multiple Object Stretch” is the tool tip displayed when you hover your mouse over
the icon in “Modify” panel of the “Express Tools” tab. Also known as “Stretch Multiple”. Sorry for misunderstanding.
The reason i look to edit or modify existing commands is that I’m not very familiar with writing codes and programing and I
find it easier to change just a bit of the existing code rather then write a new one.
See, when I open the CUI and look for “Multiple Object Stretch”, macro label shows “^C^Cmstretch”. Here I thought I can
change that default behavior.
And the STRETCH command shows “$M=$(if,$(eq,$(substr,$(getvar,cmdnames),1,4),GRIP),_stretch,^C^C_stretch)”
so I don’t have a clue about where is the option of choosing Crossing Window or Crossing Polygon hidden.
Or to make it simpler, if you type “MSTRETCH” the command line shows:
Specify an option [CP/C]
This is what I meant. It goes for C by default and I want to make CP to be default, not to type CP every time.
When I wrote my question to you, i was already on https://allaboutcad.com/tutorial-create-a-custom-command/ so
now I’ll give it a try with creating a custom command.
3 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
Adel Moldovan
July 31, 2011 at 5:08 am
Solved. Not exactly what I want but does the trick and it’s fast enough.
After MSTRETCH long mouse right click and pick CP on a shortcut drop down menu. Good
sadegh
August 25, 2011 at 7:06 am
hi.
cool tutorial.
i learn it but i have a question.
i make a new command and put it into one pallet but when i type it in command line, it dosn’t run anything.
is that normal?
i like to create some custome command that i can type them in command line.is there any way!?
(maybe i should use acad.pgp!)
thanks
Ellen
August 25, 2011 at 10:53 am
You can’t exactly type the command, but you can create a custom keyboard shortcut, such as Shift+L. I have
instructions at https://allaboutcad.com/create-a-custom-keyboard-shortcut/.
slavic
December 9, 2011 at 3:39 pm
Hi I am trying to create a custom toolbar button that will turn on a layer. So i can just click that button and that
layer turns on in the current drawing, instead of opening the layers manager to find my layer. How can I do
that? Anybody have a suggestion? I have autocad 2004.
antony john
December 17, 2011 at 10:41 am
how to change the command copy rotate command to multiple mode
mukesh ahlawat
January 6, 2012 at 2:31 am
can i record steps as in excell?
Chris
January 23, 2012 at 8:00 am
Fantastic tutorial! Saved me hours of work, thank you.
Chirag
February 9, 2012 at 11:06 pm
Hi, I am using AutoCAD Electrical 2010, I use a custom command that uses script. When I add command
display name to it, it does not work in the command line. Can you pls assist?
Vincent
February 22, 2012 at 11:51 am
4 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
Hi, I would like to know the possible macro command I can put in a custom command. I mean like setvar or
getvar.
Marcus
April 17, 2012 at 4:22 pm
Hi,
I have created a custom command to enter a block, ^C^CINSERT; TAB; RACETRACK
I want to have multiple blocks handy to easily insert. but with this command i can only insert the last inserted block…
This command opens the insert dialog box, then i want to go to the ‘browse’ button, open the block and then insert. Is this
possible? your help is much appreciated.
Thanks
Ellen
April 17, 2012 at 8:58 pm
I think you’d need some more sophisticated programming that would allow you to interface with Windows. But
if you know the name & path, you might be able to put a pause in the custom command and type the file name
and path at that point. You’d have to turn off the FILEDIA system variable. I haven’t tried this, just guessing.
Chris Eden
April 26, 2012 at 10:18 pm
Hi
i have a macro that i have been using in autocad 2012 for a simple copy & rotate command as follows
^C^C_select;auto;\_copy;p;;0,0;0,0;_move;p;;\\_rotate;p;;\\redraw
For some reason it does not work in 2013
the macro just end after the copy command and fails to rotate the objects
Any suggestions would be appreciated
Rob Rivard
May 16, 2012 at 2:58 pm
Hello,
Why is it that after this macro the layer is not returned to “0”? The macro will change to “2D_WALL”.
^C^C_-LAYER;S;”2D_WALL”;^C_BREAKLINE;\\;^C^C_-layer;S;”0″;^C;;;
Yet, with other commands ie. dimlinear it works.
Josh
May 24, 2012 at 1:01 pm
The company I work for is very strict on EVERYTHING being snapped together. I’m trying to figure out
something I can run that will hilite things that’re snapped together and point out things that aren’t snapped. It’s
an electrical systems company and I’m trying to streamline our QA process and make things easier on the drafters. Thanks
Harold
July 12, 2012 at 7:07 pm
Can anyone help me? I’m trying to create a toolbar that used to work in AutoCad 2006 but doesn’t work
anymore with 2010.
this used to work ^c^c-layer;freeze;selectobjects
When I just type it out step by step on the command line it works but instead of selectobjects I just use enter.
What am I missing???
THANK YOU!!!
5 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
Ellen
July 12, 2012 at 9:55 pm
I’ve never heard of selectobjects in a custom command (which doesn’t mean it doesn’t exist). In a custom
command, you can use ; (semi-colon) in the place of Enter or \ (back=slash) to pause for user input. See if one
of those works.
Minh
July 17, 2012 at 1:47 pm
I drew an object alongside with text in a specific scale. Is there anyway I can create a command to replicate
that object?
sbeth
July 17, 2012 at 1:50 pm
I’ve tried following your instructions numerous times… I get to a point where I make the command properly (I
hope)- including macros and choosing an icon, etc.
BUT- when it comes time to drag the new command to a toolbar, none of my panels will allow the new command to
lodge/stick there! This is also true for standard commands- i tried adding Trim to my Draw panel (so i don’t have to keep
switching b/w Trim and Extend) and it won’t let me attach it to the panel!
What am I doing wrong, anyone? thanks!
Ellen
July 17, 2012 at 8:07 pm
Are you using the ribbon? This might help: https://allaboutcad.com/tutorial-add-a-button-to-the-ribbon-in-
autocad-2009/
Ellen
July 17, 2012 at 8:10 pm
You could create a block and put it on a Tool Palette. These might help:
https://allaboutcad.com/keep-blocks-accessible-so-you-can-insert-them-in-any-drawing-part-i-tool-
palettes/
https://allaboutcad.com/change-the-scale-of-blocks-and-hatches-in-tool-palettes/
Andres Mee
September 1, 2012 at 5:30 am
Hi.
I need solution how I can execute more than one toolbutton macro sequentially In AcadLT2012.
I have problem writing macro with diesel commands, because length of macro is limited with 460 symbols.
Is it possible to call toolbuton macro from command line or other macro or script file (without toolbutton clicking)?
Irfan Ahmed
September 6, 2012 at 5:47 am
hi.
i need help to create short cut ..
actually i want to update my cad from excel so i m using OEL option,
for this first i copy a cell from excel and paste into CAD,
for paste in cad i have to do these …
from EDIT select *paste special*
thn select *paste link *
thn select *excel sheet*
6 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
and ENTER
for all above process can i creat one short cut ???
please guide me how ..
thnx
Jani Vahala
October 15, 2012 at 6:02 am
HI Ellen and thanks for this awesome site!
Could you help me with a tricky problem?
I tried to use an old macro I made years ago
and it didn´t work anymore as it used to.
Macro: ^C^C_layout;t;printtemplate.dwt;
So basically I wont to make new layouts from template with
all printing setups already made in. I am using AC2011LT in Windows 7.
If I type that same string on a command line, Acad will open
a popup window with all layouts listed in a template.
For some reason when command is ran by the macro, it will show
this text: Enter layout name(s) or [?]:
So is there a way to get the pop up -window with all layouts listed?
Putting Filedia -value to 1 didn´t help.
Thanks!!
Ellen
October 16, 2012 at 11:22 am
FILEDIA was the only idea I had…
Ranga
October 24, 2012 at 1:24 am
Dear Ellen,
I want to make macros for layers control buttons. so I have layers “0” “layer1, layer2, layer3” so i want to a button for layer
one which i press this layer “0” and “layer1” will on
Wiley1
December 26, 2012 at 2:06 pm
I am trying to make a simple macro in AutoCAD LT 2012 to save a 2012 DWG file as a 2000 DXF file. I can get
the saveas part, but how do I select the file type in the macro?
Ellen
December 26, 2012 at 8:17 pm
I’m not sure if you mean how to select the file itself.
This might help: https://allaboutcad.com/tutorial-automate-tasks-with-a-script-file/
The backslash, which lets the command pause for input, might also be of use.
Wiley1
December 27, 2012 at 11:12 am
Hi Ellen, Thank you for replying so quickly. I am able to make the backslash work, but I am trying to
accomplish this task with no manual intervention. When I have a DWG open and want to save as a DXF I click
on the save as icon, then since I want the file name to remain the same other than the file extension, all I want to do is
change the file type. If I did this manually I would just click on the “Files of type:” menu and select the “AutoCAD
7 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
2000/LT2000 DXF (*.dxf) selection and click on save. I am looking for a way to do this through a macro or script, but
cannot figure out how to do the file type selection process.
J
December 28, 2012 at 2:48 am
Hi,
I wanted to create a keyboard shortcut for Zoom In and Zoom Out while working on a plan. I created the
shortcuts SHIFT+I and SHIFT+O but need help for macro. Also, if there already is a keyboard shortcut which doesn’t need
the icon clicking please lemme know.
Regards,
Ellen Finkelstein
December 28, 2012 at 1:50 pm
I see what you mean now. It sounds to me as if you have to use AutoLISP for something like that. I’m not an
AutoLISP programmer, but you might be able to find someone to help you on autodesk’s discussion groups.
gareth
January 8, 2013 at 4:20 am
hi there im looking for a auto cad lisp to do with properts setting the colour the type and thicknes in one button.
eg a single button that gives me green, continues & 0.15 can this be done. i use 3 sets of lines as draw block
plans for a asbestose company. and thought it make life easyer to press one button rather than 3.
thanks
Gareth
Hussain
January 9, 2013 at 7:27 am
I want to chorten a command like (Wipeout). When we enter wipeout, there are options (Polyline/Frame) if i
enter F then come (On/Off). I want to go directly On or i want if i enter wipeout, its should not ask anything and
directly ON the frames.
Can some one help me please?
Habib
January 28, 2013 at 2:48 pm
Hi Ellen, I have a problem where some of my system varables are reset every time I open a acad file, I am
forced to re-enter them every time, I tried re-installing Acad but to no avail, I keep getting the same error. Can
you guide me on how to create a shortcut for setting several system variables, like HIGHLIGHT (1), FILL (on),
MBUTTONPAN(1). Thank you
SUIRAD
January 31, 2013 at 5:04 pm
how can i create a short command for xref? can you give me the exact macro?
Mikael
April 16, 2013 at 1:34 pm
Hello!
I often need to change a lot of annotative TEXT-objects (eg “123”) to/from being underlined and I am trying to
make a macro that helps me. My code jams when I click on the first TEXT item (“\” in the code) – how do I resolve this?
Code: *^C^C_ddedit \^U;
(I am using Autocad LT 2012.)
Can someone help me please!?
8 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
Robert
July 7, 2013 at 3:47 pm
I’m trying desperately to create a custom macro that would allow me to rotate the ucs on the z axis and then
initiate the plan command to follow the rotation. I’m away of using the ucsfollow command but it makes my
viewports crazy when using paperspace. I’m no good at script or writing any kind of script. Any and all help
would be appreicated. I’m using autocad 2002. I’ve got the button created already just need help with the script.
TOM
July 16, 2013 at 9:46 am
ROBERT
TRY PASTING THIS INTO YOUR BUTTON “Ucs;z;\plan;;”
IT WORKED IN MODEL SPACE AND IN MODEL SPACE INSIDE A VIEW PORT
THE \ SLASH IS USER INPUT FOR THE DESIRED ANGLE FOR Z.
TOM
July 16, 2013 at 12:29 pm
Robert
Paste this macro into your tool button.
The slash is user input for the z angle desired.
Ucs;z;\plan;;
work inside a viewport and in the model tab/space.
Randy
September 24, 2013 at 8:57 am
Robert
This is what I use. ^C^C^R_ucs_ob\_3 plan c. You pick an object, it rotates the ucs to that object, and aligns
the view to the z axis.
John
October 7, 2013 at 10:03 am
So I have a lisp routine that works perfectly to apply text to a dimension line, however, it will not put the text
below it because the command for putting text below a dim line is “\X” the “\” represents waiting for user input.
how do I get CAD to look at “\X” as complete command rather than seeing “\” then “X”?
hopefully that all makes sense
Belen
October 11, 2013 at 9:26 am
How to enter a wblock in the macro when the wblock name contains spaces? The spaces are seen by macro
as “enter”.
Belen
October 11, 2013 at 9:49 am
I got my answer already by using quotes ex. -insert;”file master logo”
9 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
Eng. Basima
March 14, 2014 at 11:31 am
hi, how can I assign the key (delete) in the keyboard to execute the command (erase) ?..thanx
Hans Graveman
March 25, 2014 at 2:44 pm
Basima
In autocad 2010/2014 de delete button wil work as erase.
Hans Graveman
Geordie Pete
April 15, 2014 at 6:27 pm
Hi, I am trying to make a makro or custom command to draw two lines 60mm apart snapped to two entities
then when finished have one line 60mm shorter than the other. This is to connect a number of pipes in a
plumbing drawing, cheers and any help would be greatly appreciated.
Tim
May 7, 2014 at 7:21 pm
I want to make a dropdown list of .dwg drawings that I can insert into .dwg drawings as I go. I work with a/c,
and want to use a library off a dropdown list.
TY
June 2, 2014 at 11:29 am
Hi,
After creating and saving a new command, AutoCAD does not recognize the command and simply says “unknown”.
Thanks
sree hari
August 14, 2014 at 12:57 am
Hi All,
i need a macro code for opening autodesk AUTOCAD 2013 and load template file(from specific location).After loading it
should draw a basic circle or rectangle diagram.
Can any one please let me know the macro command ,So that it will be help ful for me .
I want to insert a button for this ,so that once i press this button ,automatically it should undergo the above process in
Autocad software
Please let me know asap.
Harold
10 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
saman
December 13, 2014 at 11:30 pm
Hi.I will learn build customized toolbar in autocad.plz help me.
Taylor George
February 19, 2015 at 3:13 pm
I desperately need help learning how to program/create new commands, as well as adding blocks and tools to
my pallets that do not currently exist… Does anyone know of a dummy-proof site/forum/tutorial that can help
me out?
Kamal
April 1, 2015 at 5:24 am
is there any command line option available for ‘FILTER’ command?? I want to creat macro using that. I am
using 2010.
moro
May 15, 2015 at 8:16 am
After creating and saving a new command, AutoCAD does not recognize the command and simply says
“unknown”.
Thanks
Mark
June 3, 2015 at 11:08 am
Hi,
i am trying to use a custom icon in my custom toolbar to run appload and the load a lisp routine and i am not sure what
need to go into the macro line.
11 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
DON
March 7, 2016 at 8:32 am
I HAVE AN OLD CUSTOM SIDE BAR MENU THAT I WROTR FOR r19. I AM NOW RUNNING AUTOCAD
2004 AND LOOKING TO UPGRADE. mY PROBLEM IS INSERTING BLOCKS FORM THE SIDEBAR. I
PONCE USED THE cinert COMMAND BUT THAT DOES NOT SEEM TO WORK ANY MORE. iS THERE A NEW
COMMAND I CAN USE?
SYED
May 23, 2016 at 3:48 am
HI C BUTTON DOES NOT WORKING IN AUTOCAD
Floris
July 20, 2016 at 12:44 am
Hi, I’d like to always insert a block in layer 0.
Then after I done so, I’d like to return to the previous layer.
I came up with something like this but it doesn’t seem to work..
^C^C-layer;set;0;;insert;\\\layerp
Does anyone know a fix for this?
Thanks in advance
Daniel Kemack
July 27, 2016 at 3:18 pm
Hello,
I want to copy a line, down a column (like a casing), and have a classification follow it at half the distance that I copy it
down.
i.e. Soil boring’s with each soil type at certain depths and the classification to follow it at half the distance.
DAVID A MILLER
October 20, 2016 at 4:15 pm
Is it possible to create a keyboard shortcut to switch between layout tabs
Ellen Finkelstein
October 20, 2016 at 9:57 pm
Ctrl+Page Down moves you from tab to tab going to the right
Ctrl+Page Up goes left
4runner
January 24, 2017 at 6:11 pm
Hi,
I was hoping someone could help me with a macro.
I usually have zero lines of prompt history. ( in my workspace )
But when i measure a distance.
I’d like to have 3 lines of history displayed. ( so i see my measurement )
Then click, and the history would return to zero.
And i would continue working as usual.
I can get it to change from zero to 3,then the distance command,
12 of 13 10/15/2019, 8:01 AM
Tutorial: Create a custom command - AutoCAD Tips Blog https://allaboutcad.com/tutorial-create-a-custom-command/
Manoj Naik
April 15, 2017 at 8:20 am
could you tell me how can getting in excel coordinate (X,Y) is adding offset to obtained new XY coord
amirah e kahil
May 9, 2017 at 11:56 am
I created a custom command in an empty file and it worked perfectly but when I try to use it in other files it
doesn’t work
why?
sharar khan
January 10, 2018 at 3:06 pm
I want how I can make coordinats in Auto Cad in 2015
now I live in Qatar my WhatsApp number 0097466505023 if you can send me I shall be very thanks for that
Yo Stein
April 15, 2018 at 3:07 pm
yo stein
april 15, 2018
How to create commands for Autocad 2014.
Like “ew” for the command “erase window”?
Thank you for your help
Yo.
13 of 13 10/15/2019, 8:01 AM