• 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 / Creating New Command in AutoCAD

Creating New Command in AutoCAD

August 12, 2009 by Edwin Prakoso 3 Comments

cui If I’m not mistaken, AutoCAD use CUI since 2006. Not MNU or MNS as it used to be. CUI (customize user interface) is a XML file. It’s easier to manage. In this post, we will create a new command to set all properties to ByLayer. This is a request from my colleague. He likes to override color and linetype when he draw, and want to be able to reset all of the properties back to ByLayer. By clicking an icon, every properties will be set to ByLayer.

First you may want to take a look to what I want to achieve. Click here to see animation.

Let’s do it. First open CUI by accessing menu tools>customize>interface… or by typing CUI then [enter]. You will see browser like this. If you use ribbon, find it in manage tab, customization section.

cui browser

CUI browser is easier to use than creating old AutoCAD menu. There are 3 areas I would like to highlight

  1. All customization. Here is where you decide where you can access all AutoCAD tools. Either you want to put it in ribbon, tool bar, right click context menu, and even double click.
  2. Command list. Here is all your AutoCAD commands. When you create a new one, it will appear here.
  3. Properties. Here is where you can change the properties. After creating new command, you will have to define what it should do.

Let’s start. Right click on command list (2), and select new command from context menu. Rename it. Give it name ‘All ByLayer’ without quote. You can see the animation here.

Now, we have created a command. But it doesn’t know what to do yet. We have to tell it what it should do by typing macro in properties area (3). Type this macro on the macro field.

^C^C(setvar “cecolor” “ByLayer”) (setvar “celweight” -1) (setvar “celtype” “ByLayer”)

^C^C will cancel everything. Similar to pressing [esc] twice. Then we tell AutoCAD to change current color to ByLayer. Then current lineweight to ByLayer, and finally current line type to ByLayer.

Give a description that makes sense. This is optional.

We have created a new command, and give instruction what it should do when it’s executed. But AutoCAD doesn’t know yet, where you want it can be accessed. Now find it in command list. We named it ‘All ByLayer’ before.

Click and drag it to the place where you want it appear. In this example below, I put it on my layer toolbar. You can also put it on right click context menu (more about this later) or double click!

command position

Click OK on this CUI browser to finish our work. Now take a look on your layer toolbar (or anywhere you put it before). Is it there? Try it!

You can place it anywhere you want to. In this post, you can add the new command to right click (or we call it contextual menu).

Not so hard right? Learning macro is one thing, but creating customization with CUI is a lot easier than MNU or MNS. Good luck!

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

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.

3 Comments
Inline Feedbacks
View all comments
Dale Herbert
Dale Herbert
8 years ago

This command string does not work. It returns an error:

Your Command String –
^C^C(setvar “cecolor” “ByLayer”) (setvar “celweight” -1) (setvar “celtype” “ByLayer”)

Error returned –
Command: (setvar “celtype” “ByLayer”) ; error: bad argument type: (or stringp symbolp): nil

0
Reply
Hantz
Hantz
12 years ago

Sorry. but you did not create a new command. You created a macro of existing commands and used a button to execute this string of commands.

-1
Reply
piyush tyagi
piyush tyagi
13 years ago

goodmorning sir,

my name is piyushtyagi & i am a student of b.tech (from india ). first of all hw r u dear sir . so i know about u & i am so surprised to you . & i want some advised to you for my bright future & i hope you will help me .

thanks for regards,

piyushtyagi( india)

0
Reply
wpdiscuz   wpDiscuz

Featured

5 Reasons Why You Should Use AutoCAD Block (Infographics)

Here are the reasons why you should use AutoCAD blocks. If you haven’t used it, this perhaps can encourage you.

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