AutoCAD VBA - Beginner Course | Arnold H. | Skillshare
Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
39 Lessons (1h 58m)
    • 1. 00 landing video

      2:26
    • 2. 01 Introduction

      4:23
    • 3. 02 Course Content

      6:12
    • 4. 01 SetupEnv Theory

      0:47
    • 5. 02 envi setup

      3:50
    • 6. 03 vba ide Theory

      2:56
    • 7. 04 vba ide

      14:04
    • 8. 01 autocad object model1

      6:33
    • 9. 02 autocad object model2

      6:03
    • 10. 01 variables

      1:18
    • 11. 02 variables demo

      14:17
    • 12. 01 userforms controls theory

      2:20
    • 13. 02 userform labeltextboxcommandbutton

      9:53
    • 14. 03 listbox

      5:51
    • 15. 04 combobox

      9:00
    • 16. 05 frame

      3:27
    • 17. 01 conditions decisions theory

      1:18
    • 18. 02 if then else

      2:09
    • 19. 03 if then elseif

      3:43
    • 20. 04 conditional operators

      3:53
    • 21. 05 logical operators

      7:18
    • 22. 06 select case

      4:46
    • 23. 01 looping iterations theory

      1:57
    • 24. 02 do while

      4:16
    • 25. 03 do until

      1:49
    • 26. 04 for next

      2:07
    • 27. 05 for each next

      3:02
    • 28. 01 draw objects theory

      1:18
    • 29. 01 draw line

      3:10
    • 30. 03 draw line form

      7:21
    • 31. 02 draw circle

      3:07
    • 32. 03 draw text

      5:23
    • 33. 04 lwpolyline

      5:44
    • 34. 01 debugging

      0:41
    • 35. 02 debugging1

      12:22
    • 36. 03 debugging2

      2:12
    • 37. 01 errorhandling

      1:52
    • 38. 02 error handling

      12:45
    • 39. 01 conclusion

      0:43
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

112

Students

--

Projects

About This Class

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.

Who is the target audience?

  • All AutoCAD users from beginner to advanced who wanted to extend their knowledge beyond AutoCAD and be more productive.
  • This is also for AutoLISP programmers who wanted to learn a different way of manipulating AutoCAD objects.

Meet Your Teacher

Teacher Profile Image

Arnold H.

Sr. Software Developer, MCSD, MCAD

Teacher

Hello, I'm Arnold.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

phone

Transcripts

1. 00 landing video: hi there. If you're using AutoCAD in your daily work, knowing its syntax and commands, it's always good. There's no question that you cannot accomplish your work by using all the AutoCAD spilled in commands and functions. But there's just so much you can do with it. And Autodesk knows that. That is why they embedded powerful tools in AutoCAD to give users the opportunity to extend our talk its functionality beyond its Karen capabilities to empower the users due to do things that cannot be done by just using AutoCAD native commands. Hence the addition off Italy's BB, A C plus plus db, Definite and C sharp. That's the most common programming languages to extend outwards functionality. Among these languages, BV A is the most user friendly to to learn, especially for beginning programmers. It uses very simple syntax that is understandable by anyone who is just diving into the programming world. It is very easy to learn, yet it is very powerful and capable of doing almost anything past that you can think of. You can assign a fancy looking yusor in their face. You can interact with other applications like Microsoft Excel, Word Access and the best parties. Once you learn BB A, your programming knowledge is transferrable to these Softwares that uses BBS. Well, if you are still contemplating on learning your skill to supplement your current after what knowledge this is now the time to take action. Once you learn db, a new window of opportunities will open up for year. Unleash your creativity by designing your own sophisticated user interfaces and impress your manager and be one step ahead of your pierce. A new opportunities waiting. Don't delay any longer. My name is Arnold. Hey, Grit, And I encourage you to take this course and I'll see you inside. Thank you. 2. 01 Introduction: Hi. Welcome. And thank you for taking the scores. My name is Arnold. Hey, Grit and I will be your instructor. I am a maker saw Certified Solutions developer with more than 10 years of AutoCAD programming experience using maybe a an auto lease programming languages. In this course, you will learn how to create several vb A applications through a serious subject. Orioles, you learned how to use the BB eight tools to create the graphical user interface and write code. You would also explore the basics off the B B A environment by using its features to create different out what objects? Maxwell s great code to perform repetitive tasks. This is a beginner course for AutoCAD BB if you are not a god Yusor who wanted to learn programming and develop applications for auto But then this is for you. If you are an author, this programmer, and wanted to learn a different way Ah, manipulating auto hard objects, then you might find the scores very interesting. So what this v b a v b A. It is a programming environment created by Microsoft that is built into applications to automate operations. It provides tools that you can drag and drop to build a graphical user interface, or GUI, and a programming language that you can use to interact without what objects using BB A without quite allow issued to customize your Autobot application. In seemingly limited ways, it provides its own set of objects, keywords and constants that provide program flow, control, debugging and execution. What are the advantages of B B, A speed running in process with BB A. Activex applications are faster than authorities publications. It's abuse, programming, language and a development environment are very easy to use and integrated without God after it has been installed. Windows Interoperability, Active X and B B A are designed to be used with other Windows applications and provide an excellent path for communication off information across applications, which means that your excuse are transferrable to a growing number of other applications that have B B A capability. This applications include all those in the Microsoft Office family of applications such as Access Word and Excel. In addition to visual basic itself, rapid prototyping, the rapid interface development BB A provides the perfect environment for prototyping applications, even if those applications will eventually be developed in another language programmer base programmers, commonly no visual basic that Net or VB that b b A similar could be be that net and opens AutoCAD customization and application development to these programmers. Yes, well us those who are willing to learn a programming language beyond Italy. So in the next lesson, we will go through the course contents. Let's get started. 3. 02 Course Content: This will be the topics that we will be covering in this course. So these are the course contents. First off, we're going to set up our environment. For those of you who haven't set up your environment yet, we will go through the process from the loading from other describe site to installing in our applications. For those of you have already vb installed, you might have to skip this section. Next. One is we're going to explore the visual basic for application I. D or integrated development environment because that is where we will be doing lots of our coding and form design, including all the logic behind the user forms. So we will explore all that. We will also explore the different windows from within the I. D e, from the tool bars to the properties windows to watch windows to the code windows and also the object windows you would explore on that. And next, we're going to understand the our God object model. It is always better to have a good understanding of how the objects relates to each other. Like, for example, how is the layer being retrieved for how to get hold of all the layers in in the AutoCAD objects for the Texas styles or the line lives. How can we retrieve all of those? So we will ah, see how the objects are being structured from the application from the AutoCAD application route. Object to the deepest, the object a component. Oh, so the variables in V. B. A. We're going to discuss variables extensive me while our the data types that we can store in our variables and how to manipulate the values inside those variables. Next, these, we're going to explore the yusor forms in controls. V. V. A has quite a number of cultures that we can use in our program, like the command button label controls or text box with drones or missed box or combo box and some other control. Syria's explorer of that, we're going to see also some of their properties. And what are the methods behind those controls? Also, as mentioned earlier and uh, 20 object model, you can see how to retrieve all those the mayor's or nine types or starts from their respective collections. Next, we are going to learn how to use the conditions and decisions like that. If then else or if then else if they're most people conditions. I learned that you will also explored the alternative way off, providing the user some conditions like the switch statements or select statements, select cases, the statements, I mean, uh, and next, the looping and iterations These it is very, very useful when we're working on a task that thus repeated Teoh process. So the looping and adoration would be very, very useful for those kind of tuhs that's really experience do while lips due until for and consider for each Next, we will be doing less off coding by drawing different the 20 objects like Lion Circle Text LW, Hold the line. We will be coming up with different waste to draw a drawing from directly using the functionality from this drawing and modern space glasses. You're those. So get some information coming from the user input through our the sign forms. We will explore lots of that, and also it's always good to learn how to debug our code because when you are developing most of the time, you are fixing some issues leg different program errors, so it's always good to learn how to debug those schools and even exploring nothing in this section of the course. And finally, we will also be exploring how to handle those errors that you encountered when you are developing your program. So that's basically the major components. But along all of these sections, there are many different functionalities or tools that's mentioned or are used that you can learn this month. So let's get started and I'll see you in the next video. 4. 01 SetupEnv Theory: starting from AutoCAD release 2014 onwards. The V A I D e or visual basic for application integrated development environment. It's no longer embedded in the card application, So in that regard you have to download it from go out of the squibs side separately and install manually. So in this section of the course, we're going to see where to find the V B a component to be downloaded. And how are we going to install that component? No, I'll see you in the next video. 5. 02 envi setup: Okay, guys, in this lesson, we're going to download a visual basic for applications in AutoCAD. So for those of you who haven't set up the V b a i d yet you need to download it from Autodesk website. The requirement was the starting on release 2014 the 12 b b a snow longer embedded in autocad application. So you have to manually downloaded according to your, uh, operating system. So in my case, I have downloaded 2019 maybe a 1,000,000 for with those 64 bit. Just search for AutoCAD B B A and then click on be slink from other best knowledge that are the nest that come and then just choose which person you need and reach operating sees them you are currently using. So let's just don't know this 2019 maybe a 1,000,000. 100 a device. He's a self extracting file. It's an executed profile. Or in some cases, if you happen, do I have downloaded with the extension off? Shh. Uh, s f x mean? Yeah, This one here, SFX just rename it to e x e. And then you can you install it on your machine? So this is my don't try. It's currently being downloaded, but for those of you using the older versions of AutoCAD, he might already have the V A installed prior to 2014. Okay, so it is the one here. Once it's downloaded, just double click it and it should install on your machine. Run. Then choose which father you wanted to be installed Extract and starting stalling. So once you have your maybe a installed, then you can start developing applications Would be applications for God. So just follow along. All of these installer here. In my case, I have it already installed. So I don't talk to reinstall it again. This just how easy it is to set up your environment. So in the next video videos, we're going to start developing obligations. I'll see you there. 6. 03 vba ide Theory: high in this section of the course. We're going to learn the B B A i D e. We will explore the menu tool bars and see what are the functionalities are listed in each of these different menus. We will also learn how to customize the tool bars from our menus how to hide or display those different icons. Also, we're going to explore the Project Explorer window where we can work on different projects from within the the AutoCAD. I ve we're going to explore also the properties window. This is where you can see all the the properties or methods or events off different controls from within your your user forms. So we're gonna go through that also, we're going to see how the object, bro serving the works. What the What can we see from this window? Which means that we can see all of the objects and their respect the properties, methods and events. Next is we're going to see how to use also the watch window when we're doing our coding and you wanted to see the values of different variables. This is where we can find it. Next. We will also explore the toolbox window. This is the the windows where all of the yusor controls are contained. There are label controls, text controls, baton controls, list box, combo box, Chex box and Option Bus and many others. So we will go through mostly on those user controls. Also, the most important part as well is the code window where we will be doing most of our coding. We can apply different logics from our code. That's bean being triggered from the yusor menu. Are the user controls for example, a click event? How does the click event works? And how can we add code into that? Ah, container are the scaffolding of the code that vb a generates for us. So in the next video, we will explore all of these topics Here. I'll see you there. 7. 04 vba ide: Hi guys. Programming in AutoCAD B B A is done in its own development environment called vb A i d. There are two ways to open the I. D one is to five. Ah b B A I d. Come on in the common front and it should display the i d for us Another way to opened i d is through the V b a man or V v a manager Common. But this one gives us another interface where we can have some other options. Here. Let's say we can load on existing project. We can create a new project. Currently, we have ah people project here. Or we can embed the project into the drawing where we can't even define a macro in this macro window. And then when we're ready, or we can even say with us Ah BBB project. We can have help here, right? Squeaking on the help file, Children Derek us to that the right context. And when we are ready to the coding, then we can just click on this BB editor Been battle here. So now we are in the I d. Let us explore each of the component in this idea and they're quite a bunch. So let's go over each one of them. The top most. Here we have the menu bars. There we have the functionalities. They find you just hover over your mouse. You will go to some of these comments traitor on. But for now, let's just be familiarize ourselves with what's in the i. D. So below the menu bar we have here the toolbar. We can customize the appearance of the Stuber by just clicking on these toolbar options here, where we can let me guess. Go first with the standard where we can hide or show each of the icons. See that every time I and check this one, it disappears where we can just bring it back. May checking them back again. Or you can just reset the toolbar here to reset to the original configuration. So in this too. But we can also customized is by adding a few more Ah, men. Ah, two bars. So let's say the debug. Let's activate the debug it shows here. Let's operate there. Eddie, we have here you, sir, form you have here close it. We can also drug and position the two bars properly wherever we want. They just dragging from these, uh, part of the control here. Okay. Another part of the I. D is the Project Explorer window. This win window ISS used to manage our project. We can add we can add some of the components where our program, for example, the yusor form you have here the user form. And this is the toolbox where we have all the controls for our program for our user forms. So you can rename the project here. If you click on this and then you can rename Let's say ah extract Attribute these Ah, our project name. And we did this project. We have the user forms here. You can insert module in this project and so you can manage multiple projects at the time. But to do that, you have to go back to the BB a manager and you can see Then you can create a new project here. Then let's go back to the editor and this So our new project. Then we can rename these 12 any project name you can think of. Let's say just draw object project. All right, so these one project and these another project. Okay, so next part of the idea is the properties Window properties window gets populated. If we have selected a use of foreign born someone, in this case is the current form and these air all the properties of that four we have here the what is the name of the form of business? The caption This what is showing here? So that's say, test for me can see any change you make here will be showing up in this form here. And you can also changed this ice the weed, Let's say 100 or you can just drug the swan and just according me. Okay, if let's say we put in one command button here and these the current the control that is selected, it has its own respective attributes or properties here. Okay, so let's say say hello and we renamed this button CMB Say hello. This will be the name of our battle here. You can also change the color. That's saying put the background as yellow. We changed the fun too bold and size to 10. See, It's very easy and drug. He's run and it's let's see, the week you can manually changed it here. 100. You can move the left location, so there's so many properties that you can use or play around with each of the control. So the dirtiest of properties window the next one is the object browser window. So let's say if I click this one in any of your object grocer or you can press F two, it shows all the classes are or all the objects. If we select one object, let's say the acre arc. These are all the properties of the Ark. We can use all of these in our code later on, which means that all of this green we green icons, these are the methods. And all of these with the the Pointer the Hand Pointer art of properties, see, is the layer of the art, the line type nine weeks and these air the event with flashing life being here. It's called these air. The events of the art gave its modified or not so by by clicking. We are selecting each one of the properties here. It shows at the bottom here, use the layer and it is a string type. These is the function a method in return on object. It's a move. Moves the entity, object from one source from source of and destination. So this is very important the Object Explorer window. Because just by selecting the particular object or class from these miss box, you can see all the properties and methods. Okay, let's say select the line. Here, you dangle. We have the endpoint. We have the Lent. We have the start point. These are all demented. We can drip eight. You can offset second mirror. We can move. So that's about the Object Explorer window or object browser window. Another part of these i. D. Is the That's mentioned the toolbox where you can just drag and drop the control here, and another part is the watch window. This one here is used to display. The value of the variables is commonly used in the bugging. Let's say if we are stepping through our code, then you would like to examine the value of the variables that we used in our program. Then B is where you can see we will experience later on in the debugging and air handling section of the Pretoria, and another part that this very, very important is the code window. So if we double click on this button here now, we are in the court window, which means that the the event that was ah triggered is the bottle click and B B A b B a i d provided. As with these scaffolding, win the codes coupled ing, Which means if we click this one, then whatever is in this code will be executed. So let's do a simple message just to wrap up these in section. All right? Okay. Now it be if we run this program, you can just click on the screen arrow here and click on. Say hello. Hello and welcome to the course. All right. This is very exciting. Just deciding the form itself. So maybe very exciting. So we will go over true that when we start developing our codes and that's about it, for it is I d. I'd see you in the next video 8. 01 autocad object model1: Hi, guys. Let us discuss the outward object model. This is very, very important when you are developing BB A applications for AutoCAD. So this is the Ittehad structure, the top most. Here we have the application is the global, which means the AutoCAD application and under me that there is thesis preferences the documents which are also the open drawings. In AutoCAD you can open multiple drawings and the document is the particular instance of the drumming. So if you have opened three drawings and one document is, let's say the first throwing that you open and under the document or under the particular droving we have here all the collections of different ah, entity types like the blocks, dictionaries, dimension styles, groups, layer sleigh outs and so on. Let's ah, see, what are these, uh, objects? All right, imprecise Below. Here is the legend. So the blue color is the database resident entity, which means that these are built in autocad and the rectangular shape is collection. While this, uh, life green, it's also a collection. And, uh, overall shape or Shumpert shape our objects. So in each of these entity types, these are the collections off objects for example, the layers collection. So in the particular drawing, there are many layers, and you can look through that by getting the layers collection and looking to the collection so you can extract each of those individual layers. Same is true with all other collections year. Like the lion types, the exercises are the most commonly used once, and also you might know this we have here two separate branches is for the model space in the paper space. Let's concentrate on the modern space is where we can find all the different object types from three D face all the rate too Exline we have here the circle that tribute. We have the line near the holy line. We have the text, so these are all part of the modern space. That's why if you issue the destroying statement and you put a dot on it, you can see all of this object types. Let me assure you an example of how to access the layers in the layer collection. So let's see an example of that I have here created a form. It's just name it to collections form, and if we click on each of these common buttons. It should display this bottle. It should display the layers in this textile. It should display all the styles here and the line types. So let's start with the layers. I have your coated. Ah, according to display the layers. So these what I was referring to the strolling is the current drawing current. After drawing and allergies drawings, we have the layers. So currently we have these Ah autocad open blocks in tables in period. If released out our layers, we have here approximately No, it should be Layer that layers. We have year 60 layers. So if we extract this one in our drawing in our code, I mean and maybe a code. So we just need to declare the layer variable a good layer. And then now we can ah, at the rate through the layer collections and added into the list box control. This is a released backs Winkeljohn. So we ran this program and we display the layers. See, these are all the layers 16. All of them together. Now if we code the textiles, we just do the same thing. Deem. Ah, say, S t y as I had textile. Yeah. Now we can look through the ah for each the collection off styles in this drawing for each style in destroying that layers. I mean textiles. And you do the next year. Then just do the same thing. That's this box one that had items. Uh, s T y that name Miss Traitor, Run! This program misplay Textiles. Here you go. These air all our text ties. 9. 02 autocad object model2: continuing on with the previous video with us now displayed the line types. So if we code to display the line times, you just have to do the same thing just declared on appropriate variable. That's an instance of the nine types. Let's say LP as land type here and then just do the same thing for each lt. And in this drawing, the lying types do the next. So just said to display that a night air lt that name this around this program. So nine types There you go. We have here five land types. So now if we try to use the modern space when we are growing No, let me add one more about them here just to display that Yes, Seeing the explorer more than space explore more than space. Just wanted to show you how can you add object? So let's say this drawing that more than space dot So all of these objects here starting from a three D face to to explain other than the objects, there are also lots of methods. So from three D face to Exline, all you have to do is, uh and then the object type. You want to us. So this mimics exactly this list here because they're all part of the more than space. So in your type in destroying that modern space that id anything here. So that's how you use the modern space class or object. Okay, so you must the at least now have a good understanding off how you can draw on object into them one of space and also in paper space, which has only a the view port and goes to the blocks collection as well. But he's the main, the collections of objects, the more than space. When they say I lying, then each of these method adding object at circle or add ah, texts, whatever has their own respect, the arguments here or parameters that you have to specify. So for the case of flying, we have start point an endpoint. Let's say we have your ad circle we have here Descend ER and the radius. Okay, so each of these objects have their own specific arguments that you need to provide. Let's say, had text. We have here the Texas String Administration point and the height of the text all right, and other than ah methods we have seen here there quite a few other properties that the most of this space have. There's account, which means the number of objects from modern space. You can determine how many objects are there. You can also do a delete some other methods. Here you can do insert love. Okay, so that's how you draw object in the IBD. All right, so, no, we have a clear understanding off the You know, quite objects should be easier for you now to understand. If we are looking through the collections, then what do we get? All we have to do is declared appropriate object type, which means if you are looking through the dimension styles, all you have to do is specified. Ah, being style us, them styles. God, that mention style here. Okay, So make sure you are declaring appropriate variable type if you want to look through each of these specific collections. All right, so that's about for the hard object model. I hope now you have a better understanding on how to manipulate the autocad objects. I'll see you in the next video 10. 01 variables: Hey, guys, in this section of the course, we're going to discuss variables we're going to identify. What are the data types in AutoCAD B B A. Like the interior, the string, double and variant, these air all commonly used the data types in 12 b. B A. You will also declare different AutoCAD entities and store them in their variable. You will learn how to consume the values in those variables. We will also see how to display the content of those variable this values of those variables and how can we concoct innate ah, the values in variables. For example, we have two or more variables a string. Then we can concoct innate those values, you know, so see how to watch the value of those variables, and we are doing some kind of be bugging using the watch window. 11. 02 variables demo: hi guys. To further understand variables I have here created a form called FRM Variables. Basically, this former just go through each of those different variable types and then how to use them in a simple program. Let's start with declare declaring and into your variables. So this first command button here I call it common CMD ad objective is basically to just declare to numbers and add and then displayed to the user. So let's check the code for this one. So how to declare variable is using the temperament or that mentioned so deem and say I number one asked into your another defamation them to us into your Let's say we have here I thought, uh, as integral. So now we can instant sheet the value of number one se cause 10 i them to equals 12. Then I total is just the the total of those two numbers. I know someone less. I know, too. They're just going to display the total to the user using the message box. Yes, it's box, the total number IHS, and we just have to put the blast sent to coordinate the total. So in this case, the total is off into your data type. So in order for this to be who coordinated in the string, this is to be converted to string us well. So there is dysfunction called c str. This means convert the expression into a string. So in this case, it will be who coordinated. So let's around this code and see how it how it goes. Total number is blunk ways. That total number is because I put here wrong. Variable name. It has to be. I talked on the total This story again. Total number is 22. Okay, so let's run again without using the conversion function. That's I just wanted to show you was what would be the result if you don't convert the total to string. See, it says type miss much because you could not combine the interviewer and the strings. That's why this one has to be converted to a stream using the function c str or Kronenbourg to string. Okay, so now this one should work as expected. All right? No. Let's this declare a string Gaeta type and we'll congratulate those strings. So that's a dame str first name us a string and then declaring other stringers. Str last name That's a string so we can coordinate these two variables. Let's say yes, they are first name because John and last name equals gender. Oh, no. Then message box. The full name is so just concoct. Meet those two variables. First name last str last name. So that's how you can cut any strings in this case, Since this is already up string data type, you don't need to do the conversion here. Let's give it a try. Yep, So it's just a simple as that. Now let's use the ah double data type. How are you going to declare the double? I would like to use that in in a a point or creating a point so that you can see how to declare a point variable using the double data time. So let's a deem Bt one you have to put 0 to 2 last double. This is an area after the so basically there is thes point 10 0.11 and point 12 Those are the index, so that's go ahead and declare another one like the point to 0 to 2. That's double. So now if we declare the 0.10 is the X coordinate. That's just here. 0.0 pt one one. This is also 0.0. Use our why And the PT 12 is the Zet. So basically, they're just starting from zero 00 So now the PT two, this will be our endpoint of the line. Let's say 100 beauty to run this the y coordinate of the endpoint. Also, 100 right to the set would be, Yeah, zero. We don't need to do a three D. Now, in order for this to use in in creating a line object, we have to declare here another Ah, variable or the line. So Dimension Ellen has have a headline. Okay, Now we can set that line equals using that, this drawing that modern space, that ad line and supplying these two points that we have 0.1 start point and point to us the end point. All right, so if we run this one, we'll see that to create a line for us is starting from 00 to 101 100. Okay, run. That's closed. This, uh, form go back to our growing There it is. Say we check the start point from here in point of the line is 00 We also checked the endpoint off the line. It should give us 101. Okay, that's how you declared nine variable. I mean, declared the line variable based on those, uh, two points to start find and the endpoint. Okay. Mixed. Ah, is know how to declare the card objects. So we have seen this before when we discussed about the AutoCAD object model, but just to and show you again how to do that. Samos, This one here deem Linus headline. You can use any variable name you want Miss a lion as a headline or dim pls a cut Holy line . Something like that. Dempsey I as a cut circle or deem the X as a text. So those those are the waste to declare variable for the AutoCAD objects. Make sure that the variable name is s closes the object type so that it's easier for you to understand. Okay, next one here. Ah, using the variant the reason way its called variant because it accepts different types off of variables or values. So let's ah, use the let's say pt one as variant. So the objective of these code that we are writing here is to store the point that is the return of the get point function. So what we're going to do is pity one we're going to They used the PT one as our variable to start a point. So we used that these drawing that utility that get point and then we provide ah record parameters here or adoption parameters. This point here is just the reference point. So you have this kind of rubber banding effect and then just, uh, prompt the user pick a print, whatever the you sir picks could be stored in our PT one variable. But every time use the utility command with all those ah interfaces to the window, you must hide the four first. Me that hide me means the current form. In this case, if our invariable and then it will hide the form so you can make a point. And after that you could just show here me that show. Okay, so let's try that. But before we try that, I would like to provide a break point here so that we can see the value of PT one. Okay, so they wait, too. For the break point. Just click on this left side. Here. Break point means it's it's a a line in the code where your program stops or break temporarily until you continue the purpose of the break minus for you to inspect the values of those variables. So let's run this program. Click on these common bottom here, see the frontier pickup point So that speak the end point of these Very simple. Okay, Now, if I close this run, it should the continued Ah, the execution of the code. But now it it breaks in. This answer means it's still active. So all of the values of our variables here are still active wells. So now the way to inspect the value of the valuables is to put it in the watch something like this here. So it way just that will click this one and then right click and put here. So let the odd watch here and expression this point. Run, okay. And you can see it in the watch window. If you expand this value the variable you can see the values. See, 0.1 is 100 I mean the X coordinate. Appoint one. It's 100 the wise also 100 visit zero. Then you can just continue the execution. All right, so that's that's just how you use the variables. You can go through these and play around with the numbers or the values and she have, it goes. 12. 01 userforms controls theory: high in this section of the course. We're going to learn how to use the user forms and controls. We'll see how to drag and drop controls to the fore. How we can align some of those controls. We can great the control tool tips by providing them some kind off tips on what the particular control does you know. So we're going to explore the different controls in this list and their properties really go ahead and ah, explored the neighborhood. Were can we use those 11 controls? The textbooks? We'll also learn about validating the input values in those textbooks. Explored a command butter, how to use them, And where do you use them for this box control? How can we display information into the this boxes and how can we select the items in the mist box? We would go through that Same with the coma bucks. How can we bind the different mayors or styles into a combo box? We will explore that we also see how to use the check box withdrawal. Spare us the option button and there are to contender controls. This means that from within these controls, you can put multiple or individual controls. So they're called Contain nickel, Charles. So in the next couple of videos, we're going to see how all these words in action I'll see you there. 13. 02 userform labeltextboxcommandbutton: that's further explored You, sir. Forms and controls. Let's start with the yusor form. So you, sir, form itself has a lot off before functionalities, like all of these events here. So in the code window, if we only have you, sir, form object. We just this one. We don't have any control. Seriously, if we go to the code window, that is just what you can see here. Usually the form click is the default, but we're not interested in the form. Click, because we don't need to click the form what we are interested in the form use when it gets activated or when it initialize is so. There is an event for that that squeak on the user form here, and let's go over to the activate event. Let's say Let's just do a message box for activated can get rid of the So If we run this program, it executes the particular event right away because the former is already activated. B. B A is an event driven programming, which means that response to a certain event that's happening on the U. I. So in the case of the Yusor form, these are the events we can also use the initialize event. Just a message bus for initialized initialize. Okay, Mirandes again, it's just stuff person running, former initialize, former activated. So this particular event is very important or very useful. If let's say we have some controls that needs to be pre populated prior to us doing any other ah, any other event on the form, so it gives us the opportunity to populate any controlled that we want to re populated. Once the form loans, let's say we have a list box that displays all the layers in the drawing that the user can select. Or we have the combo box that we can percent to the user off the line types, for example, or the all the text styles. So that's the usefulness of those events. We will see that when we explore each one of these controls so that this for the form. Now let's continue with the the text that textbooks and the command button. Yes, they usually go together. So let me just drug one label control here, one that's bucks in one common button. The label control is mainly used for ah kind of information to guide the user what needs to be done so you can just click here. Let's say enter their name, for example. And then the text box, that is where the user has to provide the required data are required information. So these our text bus there is this ah called Hungarian notation to name the controls. So for the label, it usually starts with L B l se lbl your name and used the caption for the textbooks school Txt se layer. Come on bottom. It's surely cmd display there. Then it right here The disruption to display there something like that. And we can also use the label control to provide a status Leslie for culture for information purposes and B s where they were status, for example, or lbl info anything. And we can just keep it blank. And then once we click on this button, for example, we will display whatever delayer that is entered here. So those are the purpose of the label control, while the text bus patrol just accepts data from the user or it can be populated by a certain action from from any of these events that happens on the form. In this example, we will just use the text bus control as a source of our information. So we have Ah, remember, assist the exterior. Then we need to access this one using this Name the textbooks using this name. Okay, let's code the common bottom. For example, if I click on this button here, I am going to retrieve whatever the usury entered into the textbooks control. So I have to do ah dimension for se str layer as a stream then my str layer the value for that would be the txt layer you can type in the full name or you can just type of a portion of the name and then you can press control space. It was complete for you text. So no, let's say just miss its box the layer and third is the str layer, then B B information plus baby. Okay, only. So that's our message box that the both So we can provide another level off information to the user like we have provided the lbl info, right? The text or that value. All right. See, you think it's a corruption. It's a caption. Waas, Whatever is in the str layer, which is the textbooks str layer. Okay, Now let me deliver me. So we don't need this one for now. I run the program now, so we are prompting the user to enter the layer. Whatever layer wrong displaying the layer entered his wall. Okay. And it's also shows the layer here, so that's about for the label control textbooks. Control in the command bottom control us always. You can make these control look nicer. Depends on your color preference Can change the background there or can change the born. Anything you can play around with This, uh, properties make your form looks nicer. Are you Could change even the best color for these two to read, for example, Anything. All right. Ah, in the next lesson, we're going to explore the other controls, like the combo box list box. I'll see you there. 14. 03 listbox: Hey, guys, let us now examine the list Box control. That's what we're going to exploring this video. So I have here created another form called FRM This bucks with the caption off using this box control, let us now drive them, drop these books Cultural here the four. So let's ah, name this oneness L'Est the layer. The objective of our program here is to display all the layers in the drawing and ah, displayed here in the list box controlled container. Then we will select from this list box and display the selected layer to the user. So we have here the LST layer that's going to the code. So what we need is to populate the list box when the Yusor form he's activated. We don't need to use this Mr Form click. So let's gather all the layer in the drawing that these were driving here. Check in there. His role. The layers we have, we have 60 layers. This drawing all of these layer names will be displayed into our list box. Okay, So to do that, let's first create a variable called L A Y for layer as a cut layer. And then we are not going to look through the layer collections in this drawing using the for each function support each layer, which is our l y here in this drawing that layers here we do next. OK, so these is our layer collection and we are getting each individual layer from this collection. So what we need to do is to basically ad the layer name into the list box. So we have the A list, the layer that is our list box, that I hate them and then l y that's the layer and name that's just about it. This for each loop, will looked through the layer collections and that display individual layer names in the list box. Okay, if we run this program, here we go. These a lower layers, we have 60 layers. Okay, Now we will ah provide the list. Baxam some functionality. If let's say the use of selects a layer here, we will just displayed to the user in through the message box. So let's do that. If I double click on this Ellis, the player, this box, this is the event that's being triggered. So we need to declare a variable. It's their nature. That's a string. It's just basically to store the layer name that is selected by the user. So str layer will be no equal to Ellis. The layer the textbooks Oh, are the least box that the texts, That is the selected item. Then they're going toe do a message box selected the East Mystere layer Be information Okay on Right. That story again writing this program so that we select this second layer selected layer is Devi Windows Waas waas. So that's about it. We will use this list box in our actual program later on. But for now, it's just exciting how how it works and how again make use of its functionality. All right, that's about for the list box control. 15. 04 combobox: Let's continue exploring the user controls in this video. We're going to explore the combo box control, so I have great. And here the form for combo box name it FRM combo box. That's great. Um, Coma, Box control Dragon dropping to our form. So are purpose, or the objective of our program is to display all the line types in these combo box patrol . And we were also select from this combo box and displayed a selected attempt to the user. So that's name this Runas CBO. That's the hunger and the patient for the combo box CBO land type. So CBO nine type. Okay, now we're going to load all the lying type when the form it's active or is initialized. So let's try. The activate for was separated. Let me create a variable to hold the line times the line time I have a cut nine type and we're going to look through the lan type collection for each lt in this drawing that line types we're going to add into our combo box. So CBO mine type that I hate them. Lt that name. Okay, so that's how we're going to populate the combo box. Let's give it a try. See? Near the 12345 These These are all the land types in the drawing. Let's investigate. 12345 Okay, No, If I select any item from the combo box, there's nothing happening here because you haven't done our code. So if I double click on these control the event that this trigger is change which means that if I select any item from the control, if you will ah triggered this change. So let me great Another variable called str lt for land type string Mr. Lt was CBO healthy land type that text and then this message the user the selected nine type is being this they are It's so secretive. Title here. Line type. Okay. No, that's strange. There you go. It's like that nighttime continues but you might notice here that this is not very intuitive to the user. Which means that when the form loads, you know, is that it's nothing is displayed until we click on these Ah arrow Here. So there's another is a way to do that in the use of form activate. We can also add Okay. Ah, the first option is to either just great a label control here and then say, Select a nighttime something like that. So which means that the user has to select a lamp type and he considered a in Atlanta from here on that former box. However, if let's say we don't want this one and we just wanted to add into the list box itself or the combo box itself we can at the prompt Cirio line type that item you can put here, select a lion type and then no, this this one here there index zero, which means that it's the first I am in the combo box. Let's try that. It's already there, but it's still not showing up in the in here. You still have to click on the arrow. It should have been displayed right away. That's the default or the current text value. So what we can do is CBO line time that selected or that the least index equals zero. So that is the first, the first element in the combo box. Okay, so let's run the program. It's just you select the land time, assuring that we don't have this level control here. So at least now we can see that were prompted to select a line time we can select here. There's another problem in these code because the use rickon still select a select the land type entry, which we don't want to be happening in our code. What we can do is just provide a and, if a statement, so if they're selected text str lt it's not equal to this entry. It's not equal to these. Then we'll display the message. Otherwise, if the selected value is this one, then don't do anything. You run the program again. Select continues. Yep, it's showing up. But if we select the line time, nothing is happening. All right, so that's how it works. Let me now remove this one. This level control us. We don't need it since our code is already self. Ah, descriptive. All right. That's about for the combo box control 16. 05 frame: Hi, guys. Let us know. Discuss the frame control. So I have here added, Ah, the new you sir form and my neighborhood frm frame so that particular control is this one here. The objective of the frame is basically to group individual controls rather than having them on their own sitting on the the form. Sometimes it's better to put them inside a frame so that when you move them, it will go with the with the frame. They go together, so that is the convenient for the convenience of having a frame. For example, you can group B section into, you know, a separate frame message for the draw a line and drove text. Here. You can just include whatever control you need to draw the line and in here, whatever control you need to draw a text, and then you can freely move it anywhere on the form, and you don't have to worry about the alignment or selecting each one of them than moving accordingly. Eso It's nice to group those related controls depending on what you what you are doing with the the form. So let's say we add two more control, sir. Here for the text. The label? Yes, the insertion point. And then we add another textbooks for the insertion. So then that that's it, So you can really send the form and moved the control. We don't so much problem. You can reposition anywhere on the screen by just dragging one container rather than each of the individual controls the safe. I move this one out. Control necks and country B. See how much I have to select everyone for every single control and then places somewhere. You can do that, but there is no boundary. It's doesn't look nice if let's say they are all related into a certain task that you you would be doing, so it's better to put them inside the brain. All right, that's it for the frame. I'll see you in the next video. 17. 01 conditions decisions theory: hi guys in computer programming conditions and decisions based on logic is very important in this section of the course. We will discuss the different components in applying logic in the code. We will see how the if then else statement works and with the addition of as if statement for multiple conditions. We will also discuss the conditional operators like because to less done less or equal to greater, done greater than or equal to and not equal to, conditions. Also, we will explore and see how the logical operators work, like than not and and or and an alternative of the if then else statement. We'll also be explained by examining the select case statements. In the next video, we'll see all these being used in the actual code. 18. 02 if then else: let us now, having examples off the conditions and decisions I have here created a form called FRM conditions. So let's start me the if, then as demo. Let's examine the code of this command button. So I have here great in the code. I just declared a I know, um, variable us integer and also the magic numb variable. So basically, the objective of this code is to get a an input from the user, and we will validate that number by comparing it to our magic number here, which is five. And we're just prompting the user to enter a number from 1 to 10. If the number that the user inputs is equal to our magic number, then you dis message the correct. That is the magic number with the exclamation that arise. If it's not equal to five, then this message is Ari with a critical like on you. So let's give this a try and entering number the savory interna before Okay, sorry, that is their own number. Missed Reagan strata. Five. Correct that it's the magic number, so that's just about it for the if then else, it's a straight forward logic comparison off either the numbers or any other conditions that you may have. But the structure is always the same as this one. If then evaluate the expression, then do this. Otherwise, if it's it doesn't satisfy the condition here, it would execute the else statement, okay? 19. 03 if then elseif: in this example, we will explore the if then else if they were so let's continue building upon these form. It's examined the code for this command button. So we have here the if, then statement then we have else if in another etc. In the Els, which means that we have multiple validation compared to the 1st 1 you only have the if then else. But in this case we're validating number of times. So music sample is basically we're here, allowing the user to select an object you know, and then started object into the end variable which is defined us a identity and then you will get the object name of that entity. Then we will validate if that object name Is it a line or is it a circle or a text? If it's not one of these valid objects were just message the user that you have selected a different object. So let's try running the code I have here defined, I mean created for objects. One of this plan is a circle line text in the holy line, so that's around the eastern else. If they were, no object you selected is acerca Trey running again. Their object you selected is a line try one more time that selected text. This time the object you selected is a text. Now if we select the poli line, which is not in our validation, I mean it's in our validation. But it's in the else statement, so it should execute the else statement. You have selected a different object. So if we are to put the break point here, this for us to see what's going on behind the scene. So we select the circle. So these now are and object. That's great. They watch this one see the type here it's this card Circo. So we're validating it based on the object name, which is in this case, that a CTV Circle C So the first condition we are comparing it if it's line. So let's step over the code. Step through the codename. Is it object line? No, it's a a cbb circle. Which ISS then it satisfies this condition. So we're going to this baby's message. All right, there you go. So that's it for the if then else statement 20. 04 conditional operators: Hi guys. In this demo, we're going to explore the conditional operators. So I have here created the bottom called conditional operators. That's excitement accord behind this button. So I have here created different statements using all the conditional operators. Mistake. One sign less than less than or equal, greater than greater than or equal and not equal to the objective of these code ISS. We're getting input from the user, and then we will compare that value with our magic number here, which is five and you're just message, depending on the number that is being compared. So let's run this code. That's straight the number that it's less than our magic number straight. Three. The number is less than the magic number, which is correct. The number is less done or equal to the magic number. Still correct. It's less than the number is not equal to the magic number. Correct, because it's not equal. So let's try again and entered a number that it's larger than our magic number. C. Eight. The number is greater than the magic number. True, the number is greater done or equal to the magic number is still true. Number is not equal to the magic number. True. This time it's Ah, Put the break point here before we evaluate our third scenario. That's enter now the magic number, which is five. So our number is five and our magic number is five. So the first condition here is the I know I'm equal to the magic number in this sequel. So this message will be shown. Okay, next condition. It's the Einem. Less than the magic number. No. So this statement will be skipped. Next conversion is the number less or equal to the magic number. Yes, it is Piqua. So these statements will be executed as well. Okay, next condition is the einem greater than the magic number? Close. So this line will be skipped. Is the Anam greater or equal to the Magic Nam? Yes, it is equal to so this statement will be executed. Best condition is the einem not equal to the Magic Nam is five miss fried? So this statement translate falls because they're equal. But we were evaluating me. That's not equal to so this stress leads to falls. Which means that this statement will be skip. Okay, so that's about the conditional operators. Give it a try and see how it goes 21. 05 logical operators: All right now let's try the logical operators they are not and and or operators. So we have here a common button called logical operators. Demo the college cmd logical. That's examine the code behind this. So this is the good behind it. I just commented out the there to conditions. In the meantime, let's use the end operator first. See, I have two conditions here. The 1st 1 is I am validating the object. Name is everything is a line. Also we're validating. Is it under layer wall? If it is then you just displayed this message. Yes, that is the object I am looking for with the exclamation otherwise messages. Sorry that it's not that line is not under layer wall. So let's give this a try. By the way, before I start, this is the line reaches under layers zero and this is the line that this under earlier world. So that's select this one first. Sorry that Linus not under layer water, which means that our validation here works because although it is a line object but we have here the end logical operator which also validates the layer to be under there was reach music these two conditions should be both satisfied before it can execute this code. If either of these two are falls, then it will execute the else condition agree. So let's try one more time. Let's say we select the circle object so very stern to the else statement. That's that, Yeah, it's it's even says that it's not a line. It's just about our conditioning here in the message. But you get the logic. You people the break point here and we run the code again. That's tried these lying again. No object name. He's correct. This is true. But delayer no, it zero. So it will escape this statement and going to the else condition. See? All right, so now that's dry. The or Let me comment on this code and on comment this block here you can use these toolbar . Okay, so in this condition we have the same condition to validate it. A lion object and we're also using the end operator. And at the same time we're using the or which means that either of these conditions it's satisfied. Then it will be true because we have the or OK, so let's try that. Let's select the world first. So we have here the object name. Richest line. This is true layer. Well, this is so true. Okay, so let's step through the code. Yep. Which means that this conditions have all been satisfied. So we message the user. Now, if we try to select the layer zero line, this one will also be translate true because of the or statement here. So either of these two statements is satisfied then it translates to true because it's four . Okay, Yes, you know. So if we ran again and re select any other object other than these two lines, let's say we select the text is the object name line? No, this one itself is already pose. Although this layer is satisfied, but first condition is already formed. So we trust late to Paul's already. Yep. Okay, so that's about the the end. And or now let's try the not just comment on this. Good luck here. And, um, comment Re sports in here. So in this condition, we are evaluating Teoh Negative. Ah, assessment or negative the validation. Which means that if the object name is not in line, Daniel, display that it's the line. Otherwise that object is a line object. So let's try that. Select the text object first. That object. It's not a line. Okay, this stray running again, select the line. That object is a line object. All right. Do you put the break point here and try again? Let's see the stricken. So our object name is a circle and we're comparing it to the line. But we're doing the negative comparison, which means it's not a line. So this is true that it executes this line here. All right, so that's about the logical operators. Maybe that's right. And excitement. The results. 22. 06 select case: Our last demo for these section is the select case statement. So I have here created a button called C and the select case. Let's examine the court behind this. So same with the other examples. We are just going to select an object. We know these variables here, and then we will compare the object me and just message the user what type of object they have selected. So the syntax for the select case IHS these line here select case than, uh, the object name in this case for any condition. But in our case, we are checking the the object name and it should go with the end select statement that is the skeleton or the scaffolding. Then we will just put the the case condition. So if the object mayor is a line and should be be lying, then we will just execute this message box statement here. So this is equivalent to the if then as a statement. If LBJ name equals lined, then execute this link here. If RBG name is a circle, execute this line here, that is just more compact or lesser code. So we just provide a case statement here with and select, and then just especially by different cases. So let's give this a try. Let's select the line object. No object selected. It's a land object, which means that it satisfies the first case statement here. That story selecting another line. It's the obvious. Your name is a CD. Be lying. Yes, it is so it can execute the message box here and then exits the the conditions right away. If we select circle now Musica lying, it's not. Is it a circle? Yes, it is. So to execute this line here. Mystery selecting the text again, which is also one of our cases here. Is it the line? It's not. It's the circle. It's not into the text. Yes, it is so secure. This they're here. No, these Apollon object if we select that isn't one of our case conditions here. Is that the line? It's not a line, it's a circle instead of text. But we have here the else Which means that these skaters, for anything else except this three conditions so it could display this message back slide here. Right, So the object selected is, uh, holy land object. Okay, so that's about for the select case statement. So let's know, wrap up these section of the course should have already a good understanding of each of those conditions and decisions. You can create your own code using all of these operators and conditions. Give me that right. 23. 01 looping iterations theory: hi guys. In this section of the course, we're going to discuss the looping in iterations in AutoCAD, BB A. There are four ways to I looked through the collection or a Nari. The 1st 1 is the do while loop, which means that do while the expression is valued and keep looping until the expression becomes false, the next one that do until loop, which means that do first, then evaluate if the loop is still valid or the expression within the lip is still valid. Next, it's the four next loop, which means that look, while the pretty fine expression is still satisfied. So depending on the limit that you specified in the for next loop, then it will be executed and last one is the for each Next look. This is Ah, very ah, applicable or mainly used in the collections. For example, you have you have to iterate your, uh, collection of players or collection off styles or collections off line types, then use the for next loop. So in the next couple of videos, we're going to try each one of these and provide you some examples. So you have ah, better understanding on how and where to use all of these different looping statements. Okay, I'll see you in the next video 24. 02 do while: hi guys. Now that we have understanding flipping in iterations in B B A. Let us now try it with some examples to reinforce our learning. In the first example, we're going to use the Do I look. So I have graded here form called form, looping in adoration. So let's visit the code of this mother here. I would like to give you two examples, but for the 1st 1 let's try this very simple, looping example. So we just declared the icy tr's integer and initialized its value toe one. And we provided our do wild condition. Here do while the counter is less than six, which means that we're going toe five times and every iteration we have to incriminate our counter. Otherwise it will be infinite. So let's give these a try. The value of the counter and now is one to three or five, and it it exits the loop because we already reached the by or the six. We just this no longer valid, is not everybody. Okay, so let me comment out this one, and let's examine this little more complex example. Listen, comet, this code here, so I just initialized a variable for the identity and also he s s for selection, said I count the kind of numbers in this election said, and the counter, the objective of our program here is to select all the objects in AutoCAD. And then we looked through the entire objects collection and we just displayed object neighborhood beach object. So we have here the selection said with this name, you can name it however you want. And then we used the A C selections at all without the filter, which was every single object. You know what, and we get the number off object selected and we started in our I can't variable re initialize our counter to zero. Then we do the same thing. We looked through each of the selection said, based on the counter in the kind of the objects in the selection said, and then we just display the object name. We also said the entity in the selection said, and it is zero based index. That's why the counter he is zero, which means zero is the first NDP and so on. So let's try these code object. One is a holy line. Okay, Object to is a text object. Threes in line object for is a Stryker. That's it. So that's how do I look? Works. Give me that try. Think of something that you can look true or maybe tried in the more complex objects. I mean complex drawing with more entities, and you can experiment on each of these objects properties and see how it goes in the next video we're going to try to do until let's see you there. 25. 03 do until: the guys in this example we're going to tried to do until loop. So I have here created a button called CMB doing to look. Let's examine the court behind this bottom Do until Luke. It's very similar to the Do I look, except that instead of the do while which is in at the top, the until is right after the loop. So which missed it has to do something first, then evaluated. So do message box countries and increments until the condition here that you specified is true. Just a simple is that Let's give it a try. The value of the counter novice one to three for and five. Okay, so it's just look until this condition is satisfied. So that's just about for the do until look, if you want this example here, you can apply the same logic, which means that this portion off of the code will be at the top and the condition will be exactly the same as this one, and you're do until it will be at the bottom. Give me that. Try and see how it goes 26. 04 for next: next example is the four next loop. So we have here the bottom called CM before next. Let's examine the code. So the four next loop is basically run based on the pre determined condition here. So it is based on this number of, uh, iterations. You can specify how many operations you want, or you can base this one in the off a certain collection and then whatever you special right here, this one will be executed. How many times while this condition is true? Okay, let's give this a try. So the value of the counter now ISS one to three for five, and that's it. The good thing with the for next loop is that you don't have to increment the counter if increments by itself, because it's just basing its logic in this expression here, which means for the country equals went toe five. So it just run. 1 to 5 can put here, went 100 just run 1 to 100. Or maybe let's say you have a variable called I count run that many times from one to the count. Okay, so that's just about the for next loop. Very straightforward, straight yourself and be more comfortable using it 27. 05 for each next: Okay. Our final example in B section is the for each next loop. So we have here a button called for its next loop. That's excitement. A code for each next loop is very, very important. When you are looping through the collections, for example, here we have the layer collections, which means all layers in this drawing, we lived through each and then we just display the name. But we have to declared the corresponding object so that we are avoiding the data type miss much error. So let's check first how many layers we have here in this drawing. We have poor. I created Ah, dames stairs in wall and the people zero. So let's try running this code layer named zero wrong stairs and deems. Okay, so that is where you use the for each Next, let me create another example. Let's say for the line types will check all the land types in this drawing. Deem LTs line time. So we used for each lt in this drawing that line types next and great. The message box here. Nine type name. That's lt that name. Then read the baby information. That should be okay. Only all right. So CDs for each next just declared the LTs could land time for the object and destroying that land types for the collection. Excuse me? That try, we have to buy block by layer and continues. Okay, so that's it for our looping in iterations. I hope by now you have a very, very good understanding on how to use each one of them. You can just with whichever you prefer in your specific requirements. All right. 28. 01 draw objects theory: hi. After learning all those functions and different concepts of BB A programming, it's now a little bit more exciting. How to learn growing AutoCAD objects. So in these section, we're going to draw the following objects like the line, circle, text, lightweight poli line and the heavyweight Holy Night. So we will be using two different ways off Drawing the line object like the 1st 1 is you're going to the the utility functions. To get the points in the other way is to get the input from the user to provide us the points. Then you will also do some kind off validations into those ah data that's being entered in our controls. So in the next ah view videos, we will go through each of these objects and learn how to draw them using BB A. I'll see you there 29. 01 draw line: let us now start drawing outward objects. So in this video we're going to draw a line. Let's examine the code of this button here, but we're going to do is we are just utilizing the this drawing utility. It functions like in this case, to get point. We're in the getting the input from the user because there are many ways to draw a line. So let's just utilize the ah, God punch the BB a functionality first without interacting from the form. So we declared the 0.1 and 0.2 aspirant and Ellen this the a cut line object. And then we just hide a form so that the user can the starting point and same with the point to and then we just draw a line object out of those two points. Okay, then we just from the user we've done so let's run this code, draw a line start point and then there decline and point See that there is our line. Another thing that we can both hear you since we have the point when already we can use it . Actually, in the 0.2, it was, ah, base point 0.1. So if we draw a line, at least we have a guide already. See, that's our line. All right. So that's just how simple it is to draw a line. Just use the destroying utility, Get point to pick a point, and then when we have our two points, then what we need to do is add line and 0.1 and 0.2 and send it to the Ellen Variable. Now that we have these ah, object, we can change whatever properties, whatever properties that Len have in changed the layer for the lying type. And we can also do lots of other methods here, like rotate and scale entity. Okay, so that's just how it it's the draw A line in the next video, we're going to draw a circle. Let's see you there. 30. 03 draw line form: Now that we're done drawing a line object using the the get point method, let us now explore another way off, uh, getting input from the user. So I have here created a form called RM. Draw a line. We will let the Yusor enter the X and Y coordinates for both the start and end points. Let's examine the code. By the way, let's check the name of the controls first. So I am only interested in naming these for text boxes because that's how we get the values , whatever the user enters in these boxes. So the 1st 1 is This is I just name it. Txt x one. And this one is the t X t y one. So this for the start point in this control, here is the X t x two and this control below that is txt white too. Okay, so let's check the code for this button here. So we need to define to, uh, points variable these for the start point and these for the end point. And also we declared the Elena's a headline object. So to get the value from the text, one is just used that text property and assign it to the first. The element of the Harry of this 0.1 same thing for Hawaii and so with the second for the endpoint for the X and Y is the set reaches zero for the set. Gordon it. And then once we got all those points and we just issued these guidelines command and PT one in PT two and that's it. So let's give it a try. Let's say enter here maybe 45 and then missing the why should be 304 100 and then the the end point should be X is, uh, 800 and then the y coordinate, maybe 600. The story line. There you go. So this is our land, Okay? So everything is good. However, if let's say the yusor just click on throw line without entering any values here, what can we see there? See type Miss Much will showing their The reason behind it is ah, there is no values in these textbooks and we are converting it to double whether this is ah CDB l convert to double because the text is a string. So we need to convert it to double so that it will comply with the declaration of the data type. OK, so that's why it's Ah, it's giving us an error in this part of the code because we did not enter a value and we're converting into double. So the way to do that is either you can put the if statement that's a txt X one. That text equals nothing then so just say, miss its box, He's in there. Ah, the X coordinate. Then maybe we be critical last maybe. Okay only. And then we accept the sub right away. No need to execute the rest of the code, so go to the exit sub. Okay, let's start that one. They go so we can validate the values and then handle there properly. We can do the same thing for the y coordinate Skopje's. So where the x t y one? And just change the message here you can put here the of the starting point. It's up to you to creator message of this starting point and you can just copy over these validation code or the second court. The second ah, point the endpoint up the 10 point the y coordinate of the endpoint. Okay, That's straight. Let's say we put here 100 which is okay. Draw a line and their court y coordinate of the starting point. OK, then 200 draw a line. So we passed through the exit. Why? They're both valid then Now entered the X coordinate of the endpoint here and C 500. You're online now it's recording it of the endpoint 800. Draw a line. Nice. Okay, so that's about for using the form. You can still add other validations. The more validation should put in the lesser error. You can get Mr or some users who would like to experiment on the form. They just enter whatever value. So I leave it up to you to do the validation yourself in your coat, okay? 31. 02 draw circle: hi, guys. So in this video, we're going to draw a circle. I have graded another button here called Dross Trickle. CMD drops trickle. So let's start coding. To draw a circle, we need to have three variables. The 1st 1 is to CenterPoint. Next it's the radios, and next is the circle object itself. So let's define those street. Let's say CenterPoint for the circle s variant, you also defined the radius as double. We didn't find a circle object as a cut circle. Now we can start assigning values to those variables, so the center point should be equal to destroying that utility that get point, pick the center point, all right, And then the radius. We should assign value to that rat variable, using the destroying that utility that ah, get really function then. And they're the radius. Next is to draw the circle object so we can have set C I r equals this drawing that more than a space that circle center would be. Our CenterPoint radius will be our rod. And that's it. We cannot from to you, sir, from done. New circle is created. All right, But before we run this, we should hide the form first. Otherwise would be getting on there. Me that show. Okay, this test, This code now, draw a circle. Pick the center. Point entered the radius. Let's say 200 there is our stricken. All right, so this is just, ah, code for during a circle. Very straight forward. Get the center point first, using the get point puncture, get the radios using the get real, and then draw the circle right away using the ad circle function. Okay, give me that. Try 32. 03 draw text: Hey guys. So let's draw a text object. I have graded a new command button here called CNB Drove text. Let's do the coding. To draw a text object, we need to have four variables. The 1st 1 is the text string itself. So it's drink text string. 2nd 1 is the insertion point of the text in speed. Tia's variant in the 3rd 1 is the height of the text. So DMH diaz double from the 4th 1 is the text object the excess a text. Okay, lets start assigning values to these variables. Okay, I would like to introduce another B B A function or statement that is called Well and since we will be using a this drawing that utility for each of these three variables here the height, the insertion point and the text we can use the real that this drawing that utility and we and then we can ascend the values to those rivals like str p x equals that get string. What are the required arguments here? Houses basis. So if we type in zero, it will not accept space. But if we put in one, it will allow us to enter in the space into our Texas street. Then you can this prompt the user, Enter text. Okay. And now the height, the instruction point. I mean, realist too. Type in the dot and then get point option of Bryant and then the from you the text insertion point. Next, the height, height would be that Get ria and there text hype. All right, now that we have all those required values, we can draw our text for these. Drawing that more than space. That a text? What is the Texas string that is our str TX What is the instruction point? It's our insp et and the height that we have to assign it to a text. Uh, variable text object. Okay, have been disproved the user the it's done new pics treated. Okay, but before we run this girl, we should hide the form first and then we'll show it later on when everything is done. Okay, make note of this one here. This allows us to enter a the space. No, that's straight. Now your text. Enter text the quick brown fox. Miss the insertion point. Pick somewhere here and there. The text tight. Let's say 100. Enter there is our text. Let me show you if we put in zero here in the get string This one we let allow us to enter the space bar drove text So the space I see continues to the next line of code Right away. Insertion point big here and then next tight went on red. There is just our text. Okay, so take note of these. So put one If you want Teoh except ah, space character. All right, so that's just how to draw a text object. 33. 04 lwpolyline: Let's continue drawing and AutoCAD object in this example, we're going to draw a lightweight, poorly line. So I have graded here another button called CMD Draw LW Poorly line. Let's start coding. So let's just create a 3 30 sis like great party line. So we define our points 0 to 5 as no, but lightweight Poland only has an X and Y coordinates. There is no set, Gordon. It's so 0 to 5 means we have six ah entries into our ari. So that will be considered as three. Vert assess only nine. Let's also do you find our no variables us a cut LW party line. No, let's ah, start creating our points. So the first item in our points, Harry, that's ah start from 00 pts. Second element of an array is 0.0 So this will be the first Vertex Dax and why now? Let's continue with second Vertex. Let's save 500 for the X and for the UAE, second, Vertex of the White, also 500 and then the third vertex This a 800 and, uh, the way off the third Vertex is let's say 300 Now we can draw our life. Great Poland Destroying that more than space. That life Great holy line. And we provide a points. See the parameters here the vert desist least So what? We have the points for that. And then let's just unload the form of after the slightly older than has been drawn. And we do the zoom. All that's straight is draw a life. Great polar line Done. So these are lightweight Poland. If we examine the points, let's check first. The end of this portal in here. We should get 00 next second birth text. The end. These were text here. 505 100 and this will be 803 100. Okay, so that's about for the light. Great poli line. Now let's also draw a a natural Poland. Or should we say, a heavyweight holy line. The difference between the lightweight and ah, the normal Poland is that the Polin has ah Zet coordinates. So if we get this, you re copy this code over here. This is only considered as to very to Vertex Holy line. So let me just rename this 12 pl to make it more meaning meaning for have only line. Okay, So this one here, the ps two, the third item in an area should be the set coordinates for the first Vertex, which we just but zero. And ah, this will be ah, second Vertex. So we also need to put the zero for this That coordinate. So that's that's just about it for the points. No, that said the Folly Lane, too. Uh, parley line. And then breath asses lists of also piteous. Okay, let's Noto first we have here the life poli line. Let's change the It's changed the second birth text maybe 406 100 so that they can see where it's position drop Holy line. There you go. So this is our only land. If I need A and frying, it should be 406 100 Okay? And they have the same start point, which is 00 So that's about it for drawing the holy line and the lightweight police Give it a try yourself and experiment on the burgesses and be more familiar with it 34. 01 debugging: hi guys. In this section of the course, we're going to discuss the code debugging. We will see how to create our own break point. We will also step into the code. We will see how to step over the code and stepping out of the code and also great. They variable to watch the values. And you'll also see how to use the immediate window for our own checking off values of the variables. So I'll see you in the next couple of videos. 35. 02 debugging1: Okay, So let us now explore debugging I have here, created in a new project called They're Handling and the Bagging read one form called FRM drove text. So this is a working application that draws a text with the option to either enter our own next in the white cord in it, or pick the insertion point on the screen without so ask for the height and then draw the text or cancer. You may notice I have some background colors said, so you can pay around that too. Okay, so let's see how this, uh, obligation works. First, it's a the quick brown folks. Let's put it in the 100 100 BCE, our co ordinates and especially for the height, maybe 25 then drove the text. Here you go. Let's do so the insertion point on the screen rather than we specified a text and say to the click on this one Here, See is two text boxes get disabled and great out. Let's say we in lurched the text type of 35 drove Texan were prompted two point on the screen. Okay, let's know, examine how the code works. So this is our main function. Shoo! Shoo! All we have to define or declare our variables That is the text to get the values from the text box Insertion point the height eso the brain for to get point function You're so great here, flag. This is just to determine whether we can go ahead to draw the text old the parameters are provided. So we set the flag. Astrue we get the value of the text from the txt Text control. So this some in first the names of these text boxes. So the extra text This is the PX be exc ordinate y co ordinate the extra height. And this is the chk big point. All right, so first off we check the value. If the checkpoint is true, you be these. Then we will choose Teoh issue the get point so that the user can be the insertion point. And that is how we captured Ah, instruction. We started in the insp et variable. That's doubled here. Okay. And flag is true. Otherwise, if the CSK point value is not selected, then we go ahead with checking the values for the X coordinate the X coordinate and the white co ordinate. So if the value of the text box is not equal to non, then you get the insertion point. Otherwise, we message the user. Please enter X coordinate and we set the focus into that particular control and then set the flag poles. Next we do the same thing for the y Coordinate, Just validate if there is an entry there and we get the value of its ah populated Otherwise we issue another message Spokes saying Enter that y coordinate. And then we just these for the set. Ah, Gordon it, Yes, but zero. Then we get the height from the txt high textbooks. So if the flag is true, if it's true, then we call the the sub function to draw the text supplying the Texas string The insertion point in the height. So this one was now continue executing this line of codes here we had the text and then just message the user that X created and then continue its code now. Ah, there is this ch gay big point is the check box. If I put a break point here so you can see how it works. Say, just typing anything that big instruction point, See if the sea CSK pick point value was true. Which is true then. Ah, By pressing F eight, you can step through the code and changed the back collar to these A great privilege. Okay, so we disabled the X and Y coordinates text boxes and changed the car the degree. Okay, that's what happened here. Now, if we and check this check box is the value of the check box through No, it's false. So we enabled the the X, t x and Y coordinates and changes back to the yellow color is the equivalent. Okay. Now, speaking off the break point, we can great our break point. Either you can choose from the top if you want to go through each of the individual line. So let's start. Okay? Typing in the text here, this thing, then say 100. He's our coordinates in the height of the Texas 20 drove text. Okay, so these our break point. Now, you you can press the f a a just press f eight, and it goes one line at a time. Okay. The value of the Y coordinates not equal to nothing so stored text value. No. Since This is another function. It's sub function repress F eight again make sure that all of the parameters are provided. So let us now introduce the watch how to watch the variables. We might have used these functionality in our previous examples, but this revisited again so you can just right click on or highlighted first by double clicking it right click and add Watch will be shown in our watch window. So the value is testing. The type is string for string in integers or doubles. You can see right away the value by just hovering over our cursor here. But in the case off our A, for example, the insertion point which really find this parry of double we gonna see it here. So let's watch what's the value. But these variable you can see there is a blast sign, which means that you can expand it. So yes, we can see each of the value of the race. This is our instruction point which is valued okay and do the same thing for the height and other watch. Okay, Another way to examine the variable is to use the immediate window. You can see it from view immediate window here. Control G. So if let's say we want to check the value of SPR text can just use spring. Yes, they are text That is our text. Green baby height. That is our height where we can even examine the value of each of these expenses. That's if brain txt rye cord. So the immediate window you can after the execute. Ah, some code in there. You can access the objects, properties and methods, and you can display here. Okay, but the good thing with the watches that you see right away, you don't have to execute some of these functions just to see the values. So it's up to you. But at least we have that capability or extra features for you too. Use if you need it. Okay? No. If we are going to step true or step into this sub of function, just press f eight and it goes to this method, okay? And F eight again. So done. Now, if you want to go back, for example, you missed some of the variables in your first checking. You can just drugged the arrow and put it back here, and then you can step through again. So press F 18. All right now if I want to step out, let's say these method is quite long. I can step out by pressing the shift F eight and then control was that. 36. 03 debugging2: continuing on on the previous video. So if we are now in the sub method and we want to step out of this method, we can either a click on this Schiff, Step out means control Shift the F eight. So it should step out from this method and move to the next ah, line of code from the calling function. So that's how you do it. And then you can just continue pressing f eight or just press five to continue. And that's it. So that's just about these Ah debugging tried to play around and put ah break point anywhere on on this Ah, code and inspect. Ah, the values. You can also try stepping through the code or stepping out. Let's try there stepping out. Let's say I don't want to go through these method again. If I press f eight, then it still goes into here. But if I decide to just is there ah, over. So we should be pressing shift eight. So should continue to be lying here. Okay, then you Congar Oh, ahead with your debugging. All right. In the next video, we're going to explored the air handling. I'll see you there 37. 01 errorhandling: hi guys. Error handling is very important in VB A or in programming in general, so we're going to discuss about that. We will inspect. What are the types of errors in V. B. A. We have here the synthesis error, which means if you type in the wrong command, are wrong. Syntax. Show you an error. Those see the violation error during the compilation if you have type in the role Synthes or even when you missed some kind of closing. And if you are closing and select something like that, so those are compensation, there's they're also seed runtime errors. If, let's say the Usery invalid data and we will also add in our code different on error statement those air handling, how can we handle those type of errors? So we have here three waste do to handle their 1st 1 Is the default on air. Go to zero second on these on their go to the particular label of the Air Handler, or we can even just ignore the air and research to assume the next line of code. We also see what's in the e r R object. All right, so in the next video we'll explore all of this. I'll see you there 38. 02 error handling: let us now explore the air handling. So we will see. What are the syntax? Error? Compile ation error or runtime error. You will also examined Ah, on error statement how to use them. So let's check the code here. Synthes Airy's Synthes problem. If you missed like that, then here and then it could show you expect that then just ah, provided maybe a I. D s actually very, very ah, friendly or user friendly. It cuts the error very quickly. So for the compile ation Arab, let's say we missed out one of these. And if, for example, and the do the compilation, it says block if without. And you so these where we the group to Andy. Those are just the compile ation error. The good thing with this interaction compile ation is that you can catch them right away. But for the runtime error, it is quiet. Ah, involved to fix it and that first run of your application, you can just, ah, catch all those errors until the user tried your application. So let's say we run this program, we type in some text, and instead of typing in the correct values here, let's say they use or just typing anything. And he drove the text should give us a type mismatch error because that's that invalid. Coordinate. It's Ah, it's not you. Very. Okay, so these where we have the problem, we are storing the text value into a double data Time was defined here, so we will figure you figure it out later on. But at least now we know what are those type of run time errors. So now let's try the on Harry statement. The 1st 1 is the default IHS on error goes to zero. That is the default value, which means that we don't even need to put it here because what it does just displaced the error just pop up up out there, er so the user can see, like the one that we encountered for the type miss much. So that is the behavior. That's the default. No. If we used the on error, go to the the Error handler, The label? No, let's great label. Let's say their hunger. So if the air encounter, it should go to these label here. But we need to define these right here at the bottom of the code. But that missing taxes like this and we can displayed the air here air encountered plus the err object that description. And then we put in there critical icon. So that's how you use it. We around this program again, this thing and then anything here, whatever drove text air encountered, it hits our oh, our air 100 label. See very slight, miss much rather than rather than if they say we remove these run, then you re comment We scored first. Chris in the previous area just pops out Not very nicely. See, it's it just shows that there was not handled properly. So that's why it's always better to have these Verhaegh under that this part of your code okay. However, if you have a successful run, you don't want to go here again because without the you sure you're first what I was trying to say, even assuming that we don't have any error testing and then we put it in the 101 100 the height of the Texas 20 draw text. It draws our text, but at the same time, it's still displaced the message. But there's no error. So the way to avoid that is we should put some kind of other label here, like, done. And then just except this up. Okay, so in this case, it won't hit our label here. So if we try that again testing again and then you put it a 203 100 and canon, Here you go. We have here the message. Text graded. Here is our text. Okay. And it didn't go through the the the air hunter here. So that's how you use the air, huh? Under their on air, go to the labor. Another way to handle the code is on Air Aries. Assume next. We just coming out this, uh, code here just to show you the one error. Assume next. This is very powerful, but you have to be very, very careful because if you encounter an error here, it just continue processing it. It just ignores there, for example, we But they watch their and I mean the break point, and then make sure that it heats our error. That is supposed to be error, but if we continue f a, it ignores it because of our on air assumed next here. That's why it's kind of scary because you never know what's happening and then you just keep on going. But we have invalidate already. It happens here because we have a validation. But in this case there's nothing right. We watch and we look at the wash. There's nothing there, so that's not right. So that's how the on error resume next works. It just ignores whatever area the encounters. It's just assumed the next line of code and so on. So that is not very good practice. So let's go back to our on air handler on their go to air, hon. There. No, Remember the problem that we have here? We have the type miss much error where type in and then type miss much. Okay, So to fix this problem, we should add in an extra layer of validation. So if txt there's dysfunction called is numeric IHS knew Mary If the txt X scored the text , it's numeric. Then we started. Value is we should message the user dead. The value is invalid. You'd be critical. Okay, so now that we have these extra layer of validation, we are sure that the value that we're getting is valued number. So let's try it again. Many text here and then being something invalid value. So that's how it works. So in that case, we can apply this same validation into the white co ordinate because although the user inputs of value, but the value is invalid, so we have to trap that error. Okay? And this should be good. Now can make the message more intuitive and number only. Hurry someone you know where de center number on the okay. 100. 300 say 25. There you go. All right. So that's about our air handling tutorial. So, uh, play with it. Explore the different syntax errors, and try if you can catch the problem. Also, apply their handler and then see the description of error, okay? 39. 01 conclusion: I am now concluding this course and I would like to congratulate you for finishing. You made it. I hope the scores has been helpful to your quest off learning B B A for out God. With this new skill at your disposal, you should know, be able to address some requirements that you may have in your work or, better still, come up with ideas and develop something that you can showcase to your boss. You never know what will happen next. I believe that with this new knowledge and skill, you now have some good opportunity awaits. Just keep developing something of value and make sure to have fun while doing it. Happy, Cody, and thank you very much.