AutoCAD VBA Programming – Beginner course
This course will walk you through the VBA Integrated Development Environment (IDE). You will also learn and understand the AutoCAD VBA Object Model through presentation and examples.
We will cover the User Forms and Controls and explore AutoCAD Database Dictionary
Conditions and Decision Structures will also be covered extensively.
We will be writing actual applications using different VBA Drawing techniques.
You will also understand how to debug and handle errors in your program.
By the end of the course, you should be able to develop your own small to medium complexity applications.
In this lesson, you will have a high level overview of the course as well as get a glimpse of how and what AutoCAD VBA is. Also, you will get to know the advantages and benefits of using VBA.
Define the Course Content by outlining every single section of the course. From setting-up the environment, understanding AutoCAD Object Model to Debugging and Error Handling.
VBA Integrated Development Environment (IDE)
Discuss the content of the course as well as the requirements for installing VBA IDE. Also, identifying the versions of AutoCAD that requires separate installation of vBA IDE Component.
Walkthrough the process of downloading the VBA IDE Component from Autodesk website and installing it.
VBA IDE Components will be discussed in detail by mentioning their respective usage and purposes in relation to your programming experience.
We will examine each of the IDE Components to learn and understand how to use them in our programming as well as know their features and usage that can be very beneficial during code development.
Understanding AutoCAD Object Model in VBA
We will explore the VBA Object Model Structure and understand how the objects relate to each other and how to use and easily apply them in the code. We will go through several programs to demonstrate how they are being used by going through some of the AutoCAD Objects collections.
This is a continuation of the previous lesson where we further examine some of the AutoCAD Objects collections. By the end of this section, you should be comfortable using them and work with those objects with ease.
Using Variables in VBA
This video will explain what are the data types to be stored in a variable and how to declare them. Also, this video explains how to consume, concatenate and watch values of the variables.
This video will walk you through how to use variables with different data types. You will see 5 different programs that covers every single datatype.
User Forms and Controls
This video gives the high level overview of different controls and outline the list of Controls to be explored further and see how they work in action.
This video explores the Label, Textbox and CommandButton Controls in a simple program. It also explains the User Form and show you how to play with the Control's Properties.
This video will show you how to use the ListBox Control and how it gets populated with all the layers in the drawing.
This video will show you how to use the ComboBox Control. You will also learn how to retrieve the LineTypes in the drawing as it is being added in the ComboBox Control.
This video explores and explains the usage of CheckBox Control in a program.
This tutorial explores the OptionButton Control and compares its usage with the CheckBox Control.
This video explores the MultiPage Control in detail and uses it in the example program to generate an Audit Type Report for all the Fixtures and Doors in the drawing.
This video is a continuation of the previous one and extends its functionality by creating another page for Electrical Components.
Frame Control is very useful in grouping different controls in a single container. This video will show you how to use it when you are designing the form.
Conditionals and Decisions in VBA
Lists and explains the different conditions and decisions and operators (both Conditional and Logical) that will be explored further in the succeeding videos.
This video will show you how to use the if-then-else condition in the actual program using the InputBox to receive value from the user's input.
Sometimes there are more conditions in the program. This is where the if-then-elseif condition comes in. This video will show you how to use it by validating/checking the object type selected from the drawing.
This video will show you how to use different conditional operators in an actual program. You will have a good understanding how those conditional operators work and how to use them accordingly.
There are cases where you have to validate the program in more than one condition. This is where the logical operator works. This video will show you how to use AND, OR and NOT operators.
Another way of handling different conditions is by using Select Case Statement. This video will show you how to use it in the program.
Looping and Iterations in VBA
This video explains the 4 ways of using Looping and Iterations in your program. You will have a high level understanding on those 4 different ways.
This video will show you how to use the Do-While Loop in the program by looping through the objects in the AutoCAD drawing. You will learn how to loop through the selection set as well as how to use the counter.
This video will show you how to use the Do-Until loop and describe the differences with the Do-While Loop.
This video will show you how to use the For..Next Loop. It is the simplest form of looping in VBA and you will see it in action.
This is a very interesting video where you will see how to use the for-each-next looping structure by going through each of the Layer in the AutoCAD Dictionary. Also presented is how to loop through the LineTypes in the drawing.
Drawings Objects in VBA
This video provides a high level overview of objects to be drawn in this section.
This video will show you one way of drawing a Line object based on 2 points that uses the Getpoint function.
This video will walk you through how to get input from the user. Also, you will learn how to validate the values entered. You will learn lots of programming techniques from this video.
This video will show you how to draw a circle by using the Getpoint and Getreal Utility functions.
This video will show you how to draw a Text object by getting the values from the user's input using Getstring, Getpoint and Getreal Utility functions.
This video will show you how to draw both Lightweight and Heavyweight Polylines. You will also learn how to declare an array of doubles that will be used as a storage for the vertices.
Code Debugging in VBA
This video gives you the high level overview each topic to be covered in this section.
In this video, we will walk through the actual code debugging using the complete application to draw a text based on the user's input. You will also learn how to make changes on the Form control based on the user's action.
This is a continuation of previous video. This also show you how to create a separate sub method by calling it from the Click event code generated by the form. You will also learn how to step through/over/out of the code.
Error Handling in VBA
This video lists all the different ways of handling error in VBA. This also outlines the types of error that VBA have. The Err object is also mentioned.
This video will walk you through the process of handling error and how to remediate or fix them once encountered. This will also give you some technique on how to accept or validate user's input.