You are previewing AutoCAD Platform Customization: User Interface, AutoLISP, VBA, and Beyond.
O'Reilly logo
AutoCAD Platform Customization: User Interface, AutoLISP, VBA, and Beyond

Book Description

Take control of AutoCAD for a more efficient, streamlined workflow

AutoCAD Platform Customization is the most comprehensive guide to streamlining and personalizing the AutoCAD platform. The AutoLISP and VBA programming languages open up a myriad of customization options, and this book provides expert guidance toward applying them to AutoCAD, Civil 3D, Plant 3D, and other programs based on the Autodesk AutoCAD platform. Detailed discussions backed by real-world examples and step-by-step tutorials provide user-friendly instruction, and downloadable datasets allow for hands-on learning. Through customization you can increase screen real estate, streamline workflows, and create more accurate drawings by unleashing powerful programming languages that allow the user to command the software how to work, instead of the other way around.

AutoCAD customization is commonly performed by system administrators and CAD managers, but senior drafters and savvy users are increasingly taking customization into their own hands. AutoLISP and VBA are two popular and versatile tools that allow for going beyond the boundaries of normal user interface customization options, allowing users to:

  • Enforce drawing and CAD standards, and automate repetitive tasks

  • Customize the workspace, including tool sets, ribbon tabs and panels, and palettes

  • Modify graphical objects, set system variables, integrate with external software, and more

  • Manage blocks, change the interface, create dialog boxes, and communicate with Microsoft Office applications

  • The ideal design environment puts the tools you need right at your fingertips, removes unnecessary steps, and fosters precision through good communication. Customizing, including applying AutoLISP and VBA to AutoCAD, enables all of this and much more. For the designer who needs to work smarter because it's impossible to work any harder, AutoCAD Platform Customization provides the key information, insight, and techniques that will help to increase your productivity with AutoCAD.

    Table of Contents

    1. Cover Page
    2. Title Page
    3. Copyright
    4. Dedication
    5. Acknowledgments
    6. About the Author
    7. Contents at a Glance
    8. Contents
    9. Introduction
      1. About This Book
      2. Customization in AutoCAD
      3. AutoLISP in AutoCAD
      4. VBA in AutoCAD
      5. What to Expect
      6. Other Information
      7. Styles and Conventions of This Book
      8. Contacting the Author
    10. Part I: AutoCAD Customization: Increasing Productivity through Personalization
      1. Chapter 1: Establishing the Foundation for Drawing Standards
        1. Naming Standards for Projects and Files
        2. Managing Standards with Drawing Templates
        3. Choosing a File Format for Your Drawings
        4. Defining Plotter Configurations and Plot Styles
        5. Enforcing CAD Standards
      2. Chapter 2: Working with Nongraphical Objects
        1. Standardizing the Names of Nongraphical Objects
        2. Managing Object Properties with Layers
        3. Creating and Managing Annotation Styles
        4. Defining and Managing Other Nongraphical Objects
        5. Removing Unused Nongraphical Objects
      3. Chapter 3: Building the Real World One Block at a Time
        1. Defining and Editing a Block Definition
        2. Using and Managing Block Definitions
        3. Embedding Information in a Block Definition with Attributes
        4. Adding Dynamic Properties to a Block Definition
        5. Extracting Properties and Values from a Block Reference
      4. Chapter 4: Manipulating the Drawing Environment
        1. Getting Started with Drawing-Environment Customization
        2. Customizing the AutoCAD Startup Process
        3. Specifying Application Preferences
        4. Customizing the Elements in the Drawing Window
        5. Configuring Command and Dynamic Input
        6. Creating and Modifying Command Aliases
        7. Working with System and Environment Variables
      5. Chapter 5: Customizing the AutoCAD User Interface for Windows
        1. Getting Started with the CUI Editor
        2. Creating Commands and Defining Command Macros
        3. Customizing User-Interface Elements
        4. Setting Up Rollover Tooltips and the Quick Properties Palette
        5. Working with Customization Files
        6. Controlling the Tools on the Status Bars
      6. Chapter 6: Customizing the AutoCAD User Interface for Mac
        1. Getting Started with the Customize Dialog Box
        2. Creating Commands and Defining Command Macros
        3. Customizing User-Interface Elements
        4. Controlling the Tools on the Status Bar
      7. Chapter 7: Creating Tools and Tool Palettes
        1. What Is a Tool Palette?
        2. Using the Tool Palettes Window
        3. Defining Tool Palettes
        4. Adding and Modifying Tools
        5. Organizing Tool Palettes with Tool-Palette Groups
        6. Sharing Tool Palettes and Tool-Palette Groups
      8. Chapter 8: Automating Repetitive Tasks
        1. Creating and Running Scripts
        2. Recording Action Macros (Windows Only)
        3. What Is an Action?
      9. Chapter 9: Defining Shapes, Linetypes, and Hatch Patterns
        1. Creating and Compiling Shapes
        2. Creating and Using Custom Linetypes
        3. Creating and Applying Custom Hatch Patterns
      10. Chapter 10: Using, Loading, and Managing Custom Files
        1. Deploying Your Custom Files
        2. Using and Loading Custom Programs
        3. Backing Up and Migrating Customization
    11. Part II: AutoLISP: Productivity through Programming
      1. Chapter 11: Quick Start for New AutoLISP Programmers
        1. Working with AutoLISP Expressions
        2. Storing and Loading AutoLISP Expressions
      2. Chapter 12: Understanding AutoLISP
        1. Getting Started with AutoLISP
        2. Storing and Retrieving Values
        3. Exploring Data Types
        4. Leveraging AutoCAD and Third-Party Commands
        5. Defining and Using Custom Functions
        6. Example: Drawing a Rectangle
      3. Chapter 13: Calculating and Working with Values
        1. Calculating Values with Math Functions
        2. Manipulating Strings
        3. Converting Data Types
        4. Returning a Value from a Custom Function
        5. Exercise: Drawing a Rectangle (Revisited)
      4. Chapter 14: Working with Lists
        1. What Are Lists?
        2. Creating a List
        3. Getting an Element from a List
        4. Appending, Substituting, and Removing Elements
        5. Determining Whether an Item Exists in a List
        6. Sorting the Elements of a List
        7. Using Point Lists to Calculate Geometric Values
        8. Converting Lists to Strings and Strings to Lists
        9. Exercise: Adding Holes to the Plate
      5. Chapter 15: Requesting Input and Using Conditional and Looping Expressions
        1. Interacting with the User
        2. Conditionalizing and Branching Expressions
        3. Repeating and Looping Expressions
        4. Exercise: Getting Input from the User to Draw the Plate
      6. Chapter 16: Creating and Modifying Graphical Objects
        1. Working with Entity Names and Dotted Pairs
        2. Adding Objects to a Drawing
        3. Selecting Objects
        4. Modifying Objects
        5. Working with Complex Objects
        6. Extending an Object's Information
        7. Exercise: Creating, Querying, and Modifying Objects
      7. Chapter 17: Creating and Modifying Nongraphical Objects
        1. Working with Symbol Tables
        2. Working with Dictionaries
        3. Exercise: Creating and Incrementing Room Labels
      8. Chapter 18: Working with the Operating System and External Files
        1. Storing Information in the Windows Registry or a Plist File
        2. Accessing Data from External Files
        3. Working with Directories and Files in the Operating System
        4. Getting Information about a File
        5. Exercise: Reading and Writing Data
      9. Chapter 19: Catching and Handling Errors
        1. Identifying and Tracking Down Errors
        2. Catching Errors in a Program
        3. Defining and Using a Custom Error Handler
        4. Grouping Functions into a Single Undo Action
        5. Exercise: Handling Errors in the drawplate Function
      10. Chapter 20: Authoring, Managing, and Loading AutoLISP Programs
        1. Storing AutoLISP Expressions
        2. Writing Modular Code
        3. Adding Comments
        4. Undefining and Redefining Standard AutoCAD Commands
        5. Defining a Startup Function
        6. Loading AutoLISP Files
        7. Managing the Locations of AutoLISP Files
        8. Deploying AutoLISP Files
        9. Exercise: Deploying the drawplate Function
      11. Chapter 21: Using the Visual LISP Editor (Windows only)
        1. Accessing the Visual LISP Editor
        2. Managing AutoLISP Files with the Visual LISP Editor
        3. Formatting an AutoLISP File
        4. Validating and Debugging Code
        5. Debugging Code
        6. Creating a Visual LISP Project
        7. Compiling LSP and PRJ Files into a VLX File
        8. Exercise: Working with the Visual LISP Editor
        9. Formatting, Checking, and Debugging the badcode Function
        10. Stepping Through and Inspecting the badcode Function
        11. Creating and Compiling a Project
      12. Chapter 22: Working with ActiveX/COM Libraries (Windows only)
        1. Understanding the Basics of ActiveX
        2. Accessing Classes, Objects, and Collections
        3. Specifying Properties and Invoking Methods
        4. Working with Variants and Arrays
        5. Importing COM Libraries
        6. Using the AutoCAD COM Library
        7. Leveraging the Windows and Microsoft Office COM Libraries
      13. Chapter 23: Implementing Dialog Boxes (Windows only)
        1. What Is Dialog Control Language?
        2. Defining and Laying Out a Dialog Box
        3. Loading and Displaying a Dialog Box
        4. Interacting with and Responding to a User
        5. Exercise: Implementing a Dialog Box for the drawplate Function
    12. Part III: AutoCAD VBA: Programming with VBA and ActiveX (Windows only)
      1. Chapter 24: Understanding the AutoCAD VBA Environment
        1. What Makes Up an AutoCAD VBA Project?
        2. What You'll Need to Start
        3. Getting Started with the VBA Editor
        4. Managing VBA Programs
        5. Executing VBA Macros
        6. Accessing the AutoCAD VBA Documentation
      2. Chapter 25: Understanding Visual Basic for Applications
        1. Learning the Fundamentals of the VBA Language
        2. Exploring Data Types
        3. Comparing Values
        4. Conditionalizing and Branching Statements
        5. Repeating and Looping Expressions
      3. Chapter 26: Interacting with the Application and Documents Objects
        1. Working with the Application
        2. Managing Documents
        3. Working with System Variables
        4. Querying and Setting Application and Document Preferences
        5. Executing Commands
        6. Exercise: Setting Up a Project
      4. Chapter 27: Creating and Modifying Drawing Objects
        1. Understanding the Basics of a Drawing-Based Object
        2. Accessing Objects in a Drawing
        3. Working with Model or Paper Space
        4. Creating Graphical Objects
        5. Getting an Object in the Drawing
        6. Modifying Objects
        7. Changing Object Properties
        8. Exercise: Creating, Querying, and Modifying Objects
      5. Chapter 28: Interacting with the User and Controlling the Current View
        1. Interacting with the User
        2. Selecting Objects
        3. Performing Geometric Calculations
        4. Changing the Current View
        5. Exercise: Getting Input from the User to Draw the Plate
      6. Chapter 29: Annotating Objects
        1. Working with Text
        2. Dimensioning Objects
        3. Creating and Modifying Geometric Tolerances
        4. Adding Leaders
        5. Organizing Data with Tables
        6. Creating Fields
        7. Exercise: Adding a Label to the Plate
      7. Chapter 30: Working with Blocks and External References
        1. Managing Block Definitions
        2. Inserting and Working with Block References
        3. Managing External References
        4. Listing File Dependencies
        5. Exercise: Creating and Querying Blocks
      8. Chapter 31: Outputting Drawings
        1. Creating and Managing Layouts
        2. Displaying Model Space Objects with Viewports
        3. Controlling the Output of a Layout
        4. Plotting and Previewing a Layout
        5. Exporting and Importing File Formats
        6. Exercise: Adding a Layout to Create a Check Plot
      9. Chapter 32: Storing and Retrieving Custom Data
        1. Extending Object Information
        2. Creating and Modifying a Custom Dictionary
        3. Storing Information in the Windows Registry
        4. Exercise: Storing Custom Values for the Room Labels Program
      10. Chapter 33: Modifying the Application and Working with Events
        1. Manipulating the AutoCAD User Interface
        2. Using External Custom Programs
        3. Working with Events
        4. Exercise: Extending the User Interface and Using Events
      11. Chapter 34: Creating and Displaying User Forms
        1. Adding and Designing a User Form
        2. Placing and Arranging Controls on a User Form
        3. Changing the Appearance of a User Form or Control
        4. Defining the Behavior of a User Form or Control
        5. Displaying and Loading a User Form
        6. Exercise: Implementing a User Form for the DrawPlate Project
      12. Chapter 35: Communicating with Other Applications
        1. Referencing a Programming Library
        2. Creating and Getting an Instance of an Object
        3. Accessing a Drawing File from outside of AutoCAD
        4. Working with Microsoft Windows
        5. Reading and Writing Text Files
        6. Parsing Content in an XML File
        7. Working with Microsoft Office Applications
        8. Exercise: Reading and Writing Data
      13. Chapter 36: Handling Errors and Deploying VBA Projects
        1. Catching and Identifying Errors
        2. Debugging a VBA Project
        3. Deploying a VBA Project
        4. Exercise: Deploying the DrawPlate VBA Project
    13. Index
    14. Bonus Chapter 1: Working with 2D Objects and Object Properties
      1. Creating Other Types of Basic 2D Objects
      2. Obtaining an Object by Handle or Object ID
      3. Duplicating, Resizing, and Controlling the Display of Objects
      4. Getting the Boundary and Intersection of an Object
      5. Creating and Modifying Complex Objects
      6. Grouping Objects
      7. Setting the Draw Order of Objects
      8. Controlling the Appearance of an Object
    15. Bonus Chapter 2: Modeling in 3D Space
      1. Defining a Custom User Coordinate System
      2. Creating 3D Linear Objects
      3. Creating and Modifying Faces and Surfaces
      4. Modifying 3D Objects
      5. Working with Point Clouds
      6. Exercise: Creating a 3D Model of a Plate
    16. Bonus Chapter 3: Development Resources
      1. Online Resources
      2. Training Resources and Events
      3. Accessing and Using the Companion Website