Descripción
Aprendizajes clave
- Learn the importance of customization and task automation
- Discover which customization and automation features are available
- Learn about which additional tools might be needed
- Learn how to load and use sample programs and files
Orador
- LALee AmbrosiusLee Ambrosius is a Senior Principal Content Experience Designer at Autodesk, Inc., for the AutoCAD® and AutoCAD LT products on Windows and Mac. He works primarily on the customization, developer, and CAD administration documentation along with the user documentation. Lee has presented at over 15 different Autodesk University events on a range of topics, from general AutoCAD customization to programming with the ObjectARX technology. He has authored several AutoCAD-related books, with his most recent projects being Discovering AutoCAD 2024, and AutoCAD Platform Customization: User Interface, AutoLISP, VBA, and Beyond. When Lee isn't writing, you can find him roaming various AutoCAD community forums, posting articles on his or the AutoCAD blog, or tweeting information regarding the AutoCAD product.
LEE AMBROSIUS: Hello. And welcome to Down the Rabbit Hole, Autodesk AutoCAD Customization and Task Automation. Have you ever wanted to improve the way you work in AutoCAD? Or maybe you want to get AutoCAD to do more work for you. After all, who doesn't want their computer working away while they go get a cup of coffee or tea?
In this session, we'll be taking a high-level look at some of the AutoCAD features that will allow you to customize and personalize the user interface, help with implementing and enforcing CAD standards, and automate workflows. In addition to what I know, you should know how to use AutoCAD 2022 or AutoCAD 2016 and later, use and know what commands and system variables are. That's it-- nothing else.
Let's get started on what I hope will be an interesting look down the rabbit hole into AutoCAD customization and automation. Before we get started, though, let me introduce myself. My name is Lee Ambrosius. And I'm a Principal Learning Experience Designer at Autodesk. I'm the lead writer for the Customization, Developer, and CAD Administration documentation for AutoCAD on Windows and Mac OS. The developer documentation includes AutoLISP, ObjectARX, ActiveX VBA, manage .NET, and JavaScript.
In addition to working on the developer documentation, I am also involved with the AutoCAD Have You Tried article series and my insights for AutoCAD. I have about 25 years of experience customizing and developing applications for both AutoCAD and Windows. Over those years, I have learned about e-programming languages, with the most recent being Python. I've also written several AutoCAD books, with my most recent being under the AutoCAD Customization Platform series published by Wiley & Sons.
At the end of the day, I document the past and present of AutoCAD for the future. That's me on the right several years ago after running 48.6 miles at Walt Disney World over four days. That's a 5K, a 10K, half marathon, and full marathon. And yes, I paid Disney to run around their parks or for them to call me Dopey.
Things you should know before proceeding-- to get the most from this session, make sure you have AutoCAD 2022 installed or AutoCAD 2016 and later. The other things you'll want for this session is the handout and the additional materials. The handout takes a closer look at the topics covered in this presentation and contains links to my past AU sessions that cover the various customization and programming features that are being discussed while the additional materials contain a variety of sample files that demonstrates some of the customization and programming features in AutoCAD.
After watching this session, I recommend downloading the materials from this session's page. The handout and material files can be found under Downloads.
Introduction-- by the end of this session, you should know the benefits of customizing and automating tasks in AutoCAD, which customization and programming features are available, if and which additional tools you might need, and how to load and use the sample files in AutoCAD that are provided with this session.
Benefits of Customization and Task Automation-- hmm, have you ever thought, there's got to be a better way to get things done? Do you feel like you're going in circles or are on autopilot, repeating the same commands? But what do you do? It's just the way that AutoCAD works, right? Start one command, start the next command, and so on.
Well, it doesn't have to be that way at all. What? I know, right? Or maybe, you already knew it doesn't have to be this way. And you just didn't know how to get started. The solution is customization and automation. Customization and automation allow you to reduce training in repetitive tasks, simplify your workflows, enforce CAD standards, focus more on designing rather than the design tool, and increase business opportunities.
Wait. Time out. Rewind. I know what you're thinking. Did he just say, customization and automation? I did say customization and automation. I know what you're thinking. Nope-- I'm not a programmer, right? I can hear it already. I'm out. Exit stage right. That's a wrap. Where is the exit?
Still here? Great. Customization and automation might sound scary, but don't fear. Being a programmer isn't required. Let me repeat that. Don't fear. Being a programmer isn't required. All you need to get started is to know how to use commands and system variables.
Commands and system variables are the cornerstone of customization and automation. Hopefully, knowing this, it calms your nerves a bit. Now that you've learned about some of the benefits of customization and automation and that customization and automation doesn't necessarily mean you have to be a programmer, let's move on to learning which customization and programming options are available.
I organize customization by three expertise levels-- Basic, Intermediate and Advanced. And within these expertise levels, there are two classifications of customization-- drawing and application.
For basic customization, you will find Drawing customization techniques like blocks, layers, drawing templates among others of which are stored as part of the drawing file. While under Application customization, you will find command aliases, tool palettes, workspaces, among others. These represent files outside of a drawing file and the AutoCAD application.
For intermediate customization, you will find dynamic blocks under Drawing customization and nothing else. Dynamic blocks are more complex than regular blocks, so I felt they needed to be classified this way. Intermediate application customization techniques include scripts, user interface, custom line types, among others.
The options here are classified as Application level because none of these are stored within a drawing. You might see some familiar features here that you have heard of before, like AutoLISP or ObjectARX along with some APIs related to features that you might have used, such as CAD Standards or ETRANSMIT.
The best customization in automation features to start with are drawing templates, plot devices and plot styles, command aliases, user interface customization and workspaces, scripts, action macros, tool palettes, and user profiles. Once you get comfortable, you might consider AutoLISP programming or Visual Basic for Applications. Then after those, you might want to explore VB.NET, or C#, JavaScript, or ObjectARX.
Command Aliases to AutoLISP-- in this section, I'm going to introduce several customization automation features that leverage your knowledge of commands and system variables. Remember when I said commands in system variables were the cornerstone of customization and automation? Here's where that comes together.
I'm going to first talk about command aliases and what they are and then command sequences and how those can be converted into scripts, command macros, action macros, or even AutoLISP programs.
Command aliases-- command aliases are shortened names assigned to a command, often one to three characters in length but can be longer. They allow you to start a command without always using the ribbon and are shorter to enter than the full command name. There are few examples of command aliases-- C for circle, CO for Copy, E for Erase, L for Line, and T for Mtext. The letter to the left of the comma is the alias, and the name after the asterisk is the command that will be started when the alias is used.
A look at command sequences-- command sequences are the order in which commands are repeatedly executed. Here are a few examples of command sequences that contain the LAYER, STYLE, and MTEXT commands-- LAYER, MTEXT. LAYER, STYLE, MTEXT. STYLE, LAYER, MTEXT. And STYLE, MTEXT. Notice, the sequence always ends with the MTEXT. And what happens before MTEXT is similar in each example.
When evaluating command sequences for automation, you want to limit commands that display user interfaces, such as LAYER and STYLE. And instead, you want to use hyphenated commands as alternatives to commands that display a user interface, such as -LAYER and -STYLE.
Instead of using the layer properties manager, in the Textiles Gallery or Manager, you use the -LAYER command to manage layers when automating tasks. And you use the -STYLE command to manage textiles when automating tasks.
When possible, system variables can also be used to simplify the automation of tasks by controlling the behavior of commands and quickly accessing drawing settings. For example, the CLAYER in textile system variables can be used to set a layer current or textile current.
Command sequence to a script-- scripts execute a sequence of commands, options, and values. They cannot request input from the user. And they are stored in files with an SCR extension. Scripts are great for automating tasks such as drawings setup, creating layers and styles in a drawing, and migrating from one set of CAD standards to another.
Here's an example of a command sequence that sets the drawing limits, creates new layers, inserts a block, zooms to the extents of the drawing, and enables orthomode, disables grid and snapmodes, and sets running object snaps using system variables, all before setting the drafting and annotation workspace current.
Here's what the previous command sequence looks like as a script. The commands, options, and values can be on separate lines. Or a command and its associated options and values can be on the same line. Now I'm going to switch over to AutoCAD to run the sample script file.
With AutoCAD open, I'm going to add a few paths to the file settings in the Options dialog box. These paths are to help AutoCAD locate this session's sample files.
After adding the file settings, I'm going to load a custom customization file created for this session with the CUILOAD command. From the Custom Ribbon tab, I'm going to open the sample script file. Here's what the sample script file looks like.
Now, I'm going to switch back to AutoCAD and run the sample script file. Notice the title block has been inserted, and the drafting and annotation workspace has been set current along with the creation of layers and the adjustment of the drafting aids.
Command sequence to command macro-- command macros can be executed from the Ribbon, Quick Access Toolbar, and Tool Palettes window. They can be used to start a single command with no options or values to something more complex with multiple commands and provided options and values. And unlike scripts, command macros can request user input.
Here's an example of a command sequence that sets a layer current, sets a textile current, and then allows the user to create a multi-line text object. Here's what the previous command sequence looks like as a command macro. It sets a layer current, sets a textile current, and then allows the user to create a multi-line text object.
Command macros often start with one or more caret or Control-C sequences which represent a single pressing of the Escape key. The command names, options, and values in this example are indicated by the orange color. Each semicolon represents the pressing of the Enter key. And a backslash character represents a request or pause for user input.
Command macros are stored in customization files. A customization file is edited using the Customize User Interface Editor. Now I'm going to switch over to AutoCAD and show the Customize User Interface Editor in the command macro from the previous example.
With AutoCAD open, I'm going to click the Manage tab and then User Interface to display the Customize User Interface Editor. The custom command macros for this session are stored in the partial customization file I loaded earlier. I'm going to choose AU2021.cuix from the Customization Files dropdown list.
The Command List pane is where you'll find the commands that can be added to the Ribbon, Quick Access Toolbar, Tool Palettes, among other user interface elements. I'm going to select the My Text command, which contains the custom command macro. You can see the command's macro in the Properties pane, and it can also be viewed and edited in the Long String Editor.
From the AU My Tools tab, I'm going to click My Text and specify two points and enter the text, HELLO AU. Notice the text is blue, and placed on the TS-TEXT2 layer, and assigned the Sans Serif Bold textile.
Command sequence to action macro-- action macros are easy to create as they're created directly in the AutoCAD user interface. There is no need to transform commands and their option values into a different format like you saw with scripts in command macros. Action macros do provide the ability to prompt for user input during playback, unlike scripts. And they are stored in files with an ACTM extension. Once created, there are limited changes that can be made. Values can be edited. Recorded commands can be removed. But additional commands cannot be appended or inserted.
Here's an example of a command sequence that sets a layer textile current before prompting the user to create a multi-line text object. Here's what the previous command sequence might look like as an action macro in the action recorder. Now I'm going to switch over to AutoCAD and show the previous example of an action macro in the action recorder.
With AutoCAD open, I'm going to click the Manage tab and select the action macro named MYTEXT_ACTMACRO. Now if I expand the Action Recorder panel, the commands, options, and values that were recorded as part of the action macro can be viewed. Clicking the Play button allows me to playback the selected action macro.
After playback starts, I can specify two points and enter some text to create the multi-line text object.
Command sequenced in AutoLISP program. AutoLISP allows for defining custom commands, calculating and storing values, performing choices based on drawing-based conditions, and requesting user input. To get started with AutoLISP, list you just need to know five core functions-- COMMAND, SETQ, SETVAR, GETVAR, and DEFUN.
Here's an example of a command sequence that sets a layer and textile current before prompting the user to create a multi-line text object. Here's what the previous command sequence might look like as an AutoLISP program. Setting a layer current, setting a textile current, and then allowing you to create a multi-line text object.
AutoLISP statements must start with an open parenthesis and end with a closing parenthesis. The command names, options, and values in this example are indicated by the orange color. String values are represented by double quotation marks. Empty quotation marks represent the pressing of the Enter key. And a pause variable is used to indicate a request for user input when using the command function.
Now I'm going to switch over to AutoCAD and show the AutoLISP program in the previous example. With AutoCAD open, I'm going to click the AU - My Tools tab and click Open AutoLISP Samples. Here's what the AutoLISP statements look like in the sample file. The MYTEXT_AutoLISP command is defined at the top. I'm going to switch back to AutoCAD to load the sample file and then run a custom command.
From the AutoLISP dropdown menu, I'm going to click MyText. This will start the MYTEXT_AutoLISP command defined in the sample file. After the command starts, I'll specify two points and enter some text to create the multi-line text object.
Now that you've seen some of the customization programming features in AutoCAD, let's move on to learning about the tools needed to take advantage of these customization programming features. What tools do you need? For many customization programming features, all you need to use are the utilities in AutoCAD 2022 or AutoCAD 2016 and later along with Notepad in Windows.
Here are the tools used for many of the drawing-based customization features. Here are some of the tools used for the application-based customization features. Here are some of the other tools used for the application-based customization programming features. The tools used to create programs with JavaScript. .NET and ObjectARX can be found in this session's handout.
Now that you've learned which tools can be used to customize and automate tests in AutoCAD, let's move on to learning how to load the sample files available with the session. Based on time, I'm only going to discuss the commands you need to know. You can find the specific steps in this session's handout on how to load and use each of the sample files.
Load and use the sample applications-- this UI load command is used to load partial customization files, like the one in this session's materials that contains the AU - My Tools Ribbon tab and its associated custom macros. The SCRIPT command is used to run script files.
Action macro files are automatically loaded as long as AutoCAD knows where they're stored. Once loaded, you can choose the macro from the Action Recorder panel, or enter the name of the action macro at the command prompt and play it back. AutoLISP and ObjectARX files can be loaded using the APPLOAD command. Once loaded, you can enter the name of a defined command at the command prompt.
The VBALOAD command is used to load a VBA project. Once loaded, you can run a defined macro in the project using the VBARUN command.
The NETLOAD command is used to load managed .NET Assembly files. Once loaded, you can enter the name of the defined command at the command prompt. The WEBLOAD command is used to load JavaScript files. Once loaded, you can enter the name of a defined command at the command prompt.
Where to get more information-- Autodesk University offers a wealth of information. Here are some of the sessions that I have presented in the past related to customizing and automating tasks in AutoCAD. Along with the sessions I have presented, you can also find many other great sessions by other speakers.
The AutoCAD customization and developer guides provide reference information on customization and programming features. Have You Tried articles offer a quick overview of some of the available customization features. Discussion forums allow you to ask questions and get a response from peers and Autodesk employees, while internet search engines can be used to locate additional resources and examples. Books can also be a great option for learning AutoCAD customizations programming.
Final thoughts-- this brings us to the end of our journey into look at customizing and automating tasks in AutoCAD. I hope you found this session interesting. Customization and programming features allow you to enhance your productivity and improve or introduce new workflows. When I first started to use AutoCAD, I found repetitive tasks boring-- I mean, really boring-- and felt there had to be a better way to get my work done.
This led me to learn how to customize and program AutoCAD. I never thought of myself as a programmer. But I couldn't continue doing what I was doing without going a bit crazy. In the end, it opened up doors to many wondrous journeys. This, to me, is just like wonderland in Lewis Carroll's Alice's Adventures. Wonderland was virtually endless and full of mysterious wonders.
If you have any questions, post a comment on the session's page. Or feel free to email me, and I will get back to you as soon as I can. Thanks for watching this session.
Downloads
Etiquetas
Producto | |
Sectores | |
Temas |