Tutorial_ Create a Custom Command in Autocad

4
« Tutorial: Create a custom wor kspace in AutoCAD 2006 a nd later  How to stay up to d ate with AutoCAD » 1 tweet retweet 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! Enter cui at the command line/dynamic tooltip to open the Customize User Interface dialog box. 1. In the Command List pane, click New (Create a New Command). 2 . In th e P roperties pane, enter a nam e for the comm and in th e Name tex t box. Also enter a description in th e Description text box. 3 . 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. 4. Below are the special characters you need to know for menu macros: Char act er Descr ipt ion Space Equivalent to pressing Enter except when entering text to create a text object that contains spaces (between words). Use between the command and its options. ; (semi-colon) 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 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 beginn ing of a m acro, before ^ C^ C, repeats the macro until you press Esc or choose another menu item. ^ P  T og g les t he di sp l ay of the menu macro on t he command line; makes the macro look neater when you use it. utorial: Create a custom comm and htt p://www.ellenfinkelst ein.com /acadblog/t utorial-creat e-a-custom-command/ 1 of 4 11/10/2011 1:39 PM

Transcript of Tutorial_ Create a Custom Command in Autocad

Page 1: Tutorial_ Create a Custom Command in Autocad

7/28/2019 Tutorial_ Create a Custom Command in Autocad

http://slidepdf.com/reader/full/tutorial-create-a-custom-command-in-autocad 1/4

« Tutorial: Create a custom workspace in AutoCAD

2006 and later  

How to stay up to date with AutoCAD »

1tweet

retweet

If you find yourself using the same combination of commands and options over and over, you can easilycreate 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. Noprogramming required!

Enter cui at the command line/dynamic tooltip to open the Customize User Interface dialog box.1.In the Command List pane, click New (Create a New Command).2.In the Properties pane, enter a name for the command in the Name text box. Also enter a description in theDescription text box.

3.

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 andoptions as you would enter them on the command line or in a script. Then add any necessary special

characters.

4.

Below are the special characters you need to know for menu macros:

Character Description

SpaceEquivalent to pressing Enter except when entering textto create a text object that contains spaces (betweenwords). Use between the command and its options.

; (semi-colon)

Equivalent to pressing Enter. The end of a line in amenu macro is also equivalent to pressing Enter. Morehelpful than using a space when you need to pressEnter twice, because it shows the number of Entersmore clearly. Also helpful at the end of the macro.

\Pauses for user input, such as picking a point orentering a value.

+At the end of a macro line, continues the macro to thenext line

*At the beginning of a macro, before C C, repeats themacro until you press Esc or choose another menuitem.

P Toggles the display of the menu macro on thecommand line; makes the macro look neater whenyou use it.

ial: Create a custom command http://www.ellenfinkelstein.com/acadblog/tutorial-create-a-custom-c

11/10/2011

Page 2: Tutorial_ Create a Custom Command in Autocad

7/28/2019 Tutorial_ Create a Custom Command in Autocad

http://slidepdf.com/reader/full/tutorial-create-a-custom-command-in-autocad 2/4

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.

1.

If you drag it to a toolbar, use the Button Editor to give it an image. Usually, you choose an existing button tostart with, click Edit, and modify it. Then click the Save As button to save the icon image.

2.

Click OK and try out your new command!3.

Related posts:

Creating Custom Toolbar Buttons1.Tutorial: Create a custom simple linetype2.Create a custom toolbar in AutoCAD 2006 or later 3.Tutorial: Create a custom visual sty le in AutoCAD4.Ending the LINE command quickly5.

February 3rd, 2008 | Tags: command, commands, interface | Category: Customization

7 comments to Tutorial: Create a custom command

Create a custom keyboard shortcut « AutoCAD Tips Blog J uly 4th, 2011 at 4:16 pm

MORE Dropbox Space Get 250M in EXTRA storage space when you join Dropbox. It's free! dropbox.com

Free 3D CAD for Architect ArchiCAD 15 — 3D modeling tool for architects & interior designers! myArchicad.com/freeDownlo

MachineWorks The leading Software Toolkit For CNC Simulation And Verification www.machineworks.com

ial: Create a custom command http://www.ellenfinkelstein.com/acadblog/tutorial-create-a-custom-c

11/10/2011

Page 3: Tutorial_ Create a Custom Command in Autocad

7/28/2019 Tutorial_ Create a Custom Command in Autocad

http://slidepdf.com/reader/full/tutorial-create-a-custom-command-in-autocad 3/4

[...] For information on how to create a custom command, see this tip. What keyboard shortcuts do you use?Leave a comment! Please also explain what they do, in case it [...]

Adel Moldovan J uly 30th, 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 arrowkeyboard 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 J uly 30th, 2011 at 11:25 am

Are you just talking about the STRETCH command? I’ve never heard the phrase “Multiple ObjectStretch,” 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 ribbonpanel. I have instructions here: http://www.ellenfinkelstein.com/acadblog/tutorial-create-a-custom-

command/. This might also help — http://www.ellenfinkelstein.com

/AutoCAD_tips_create_custom_toolbar_cui.html — although it describes adding a button to a toolbar, ratherthan to the ribbon.

Adel Moldovan J uly 31st, 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 yourmouse over the icon in “Modify” panel of the “Express Tools” tab. Also known as “Stretch Multiple”. Sorry formisunderstanding.

 The reason i look to edit or modify existing commands is that I’m not very familiar with writing codes andprograming 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 Ithought 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 http://www.ellenfinkelstein.com/acadblog/tutorial-create-

a-custom-command/ so now I’ll give it a try with creating a custom command.

Anyhow, thank you for your time.

ial: Create a custom command http://www.ellenfinkelstein.com/acadblog/tutorial-create-a-custom-c

11/10/2011

Page 4: Tutorial_ Create a Custom Command in Autocad

7/28/2019 Tutorial_ Create a Custom Command in Autocad

http://slidepdf.com/reader/full/tutorial-create-a-custom-command-in-autocad 4/4

Adel Moldovan J uly 31st, 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

sadeghAugust 25th, 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

EllenAugust 25th, 2011 at 10:53 am

 You can’t exactly type the command, but you can create a custom keyboard shortcut, such asShift+L. I have instructions at http://www.ellenfinkelstein.com/acadblog/create-a-custom-

keyboard-shortcut/.

ial: Create a custom command http://www.ellenfinkelstein.com/acadblog/tutorial-create-a-custom-c

11/10/2011