AU Class
AU Class
class - AU

Expand Your Programming Ability with AI

共享此课程
在视频、演示文稿幻灯片和讲义中搜索关键字:

说明

Artificial intelligence (AI) has the potential to significantly affect our industry. How can we use AI to improve our programming skills and make us more efficient? In this session, we'll go over the creation of a program using LISP to copy files from one location to another. Once created, we will use AI to convert a portion of that code into a visual basic script (VBS) so that the user can continue to work while files copy in the background.

主要学习内容

  • Learn about how to choose which AI to meet your needs.
  • Explore how we should teach the AI certain information to begin the process, considering that AI needs to be taught before it can return a result.
  • Learn how can we convert the program to another language, once the program is written in a language that we know.

讲师

  • Michael Steffinger
    Over his 25 years in the civil engineering field, Mr. Steffinger has worked on a variety of projects in Single-family, multi-family, light-industrial, and commercial for private and public developers; federal, state and local governments; and major utilities. The days Mr. Steffinger works in the Reno, NV area where he is adding training and mentoring to his design and programming skill set.
Video Player is loading.
Current Time 0:00
Duration 0:00
Loaded: 0%
Stream Type LIVE
Remaining Time 0:00
 
1x
  • Chapters
  • descriptions off, selected
  • subtitles off, selected
      Transcript

      MICHAEL STEFFINGER: Welcome to Expanding Your Programming Ability with AI. I'm Michael Steffinger. I'm currently a designer with Kimley-Horn. I've been in the industry since 2002 and have worked on a variety of projects throughout the US as well as internationally.

      AI has been fairly new to me. I've been using it for about two years, and it has definitely helped me to become a better programmer. I have been toodling around with programming for the better part of five years. And with the ability of AI, I have been able to move beyond some of the Lisp routines that are standard inside AutoCAD and have started to develop other routines and scripts to help me with my day-to-day.

      So one of the things that we're going to be discussing here is we're going to start off with, basically, why am I presenting this? We'll move on to the items that I look for when am trying to pick an AI, the pros and cons for a few things. We'll then use AI in order to write some very generic, basic code. We'll have a few instances of that.

      Then, I will use AI in order to translate the code to another language. In this case, the two languages will be a simple BAT file as well as a VBS. And part of the reason why I'm doing a BAT file and a VBS rather than .NET or something is essentially due to the simplicity and time constraints associated with this. Finally, we'll get into some of the testing and verification processes that will help to move forward since AI is not going to be perfect.

      So why present on AI and programming? I'm sure everybody that sitting in the room has heard of AI. Based off of news reports, some people might think that AI is going to steal your job. Other people are going to think of AI as a mechanism in order to expand their capabilities. And it is that latter argument that I am here to emphasize.

      AI isn't going to magically take away our jobs. It can be another tool that we can use in order to make ourselves and the company more profitable and hireable. So talking about AI and what its capabilities are can be important, and understanding where its restrictions and limitations are can also help us.

      So that gets us into the next section for how to pick an AI. Three of the items that I am looking for when I pick an AI-- I want something that's going to use a common or natural language. There are AI's out there that many of you are probably using in your daily lives, such as Siri, or Google, or some of the voice-based AI's.

      The reason why I want to use a common or a natural language one is because I don't want to have to type while I'm listening to Siri, or Alexa, or somebody dictate what that code is supposed to be. Coding is already difficult enough when we consider semicolons, and comments, and various syntax that needs to be in place that we don't need to complicate that with trying to understand what is being said to us as it is being spoken.

      The next thing that I'm looking for is the ability to save the results. So some of the APIs that are out there-- many of the AI's in fact-- will actually state that they don't save the results. And while in testing, I haven't found this to be 100% true, there are times where it is more difficult due to an interface change for me to access some of those previous conversations.

      And I have found some of the conversations tend to disappear over time. I, for one, don't typically have an entire day or even a week to concentrate on just writing code. Usually, when I need to come up with some sort of program, I'm doing that on a spur of the moment item, maybe during some free time between billable projects, billable work. And I need to have the ability to come back, pick up where I left off and continue from there.

      The next is the ability to understand the languages that are being requested. So AutoLISP isn't going to be as prevalent in many of the AI as something like .NET, or C++, Java, Python, things like that. The AI's do a fantastic job at bringing some of that information in, but it is not going to be 100% perfect.

      I'm not a programming expert, and I will never fully stand up and say that I am. But I imagine that that truth remains even for C++, Java, and some of the other larger ones that are out there. But being able to use the AI for what I need is going to be very important.

      So that brings us to the AI's that I have found that meet this criteria. Most people have heard of ChatGPT, so that's the first one that's listed on there. Because Microsoft Copilot is based on ChatGPT, I'm also listing it, but I do tend to get some slightly different results when working with Copilot versus working with ChatGPT. So it can be beneficial here to use both because you might be able to then find an alternative to your code. Maybe it'll will explain the code a little bit better. Maybe it will provide an alternative that is a little bit more efficient, less lines, faster, however you want to measure that.

      The third option is Google's Gemini project. And then finally, we have Venus AI. Venus AI is the newcomer in regards to the AI's that I have been using. And of the four, it so far has produced some of the least desirable results. I still mention it because I'm hoping that it will be another tool out there and pick up with the other projects and start to incorporate some other techniques, and some other languages, and give me some better results over time.

      So let's first start off here by comparing the different AI's. What can each one do for us? What are the limitations here. So I'm going to go ahead and post to all four of the AI's this question.

      I want the AI to create a AutoCAD Lisp file that will draw a circle at the center of x equals 150 and y equals 250 with a radius of 50, and circumscribe that circle with a hexagon. So let me just go ahead and copy this over to the AI. So the first will be inside ChatGPT. So I'm going to go ahead and paste that. Press Enter here. And it's starting to give me the results that I'm looking for.

      So we'll go a little bit over the code here in case there are some people that have not used-- or are unfamiliar with AutoCAD Lisp. So the first line here is the defining of a function. In this case, it's called draw circle in hexagon. It's creating a variable called center with an x value of 150, and a y value of 250, and the radius of 50.

      Then, it is executing that command to draw the circle given the parameters of the variables center and radius. And then it's drawing a polygon going around each of the angle points in order to create that polygon, generating the polyline command, feeding that information, and then finally attempting to close out of the polyline. Let's go ahead and copy this code into AutoCAD and see what it generates for us.

      So we'll paste that in. We're going to go ahead and load that up. Oh, sorry. I pasted that into the wrong window. Paste that into this window. Load that up. Go over to AutoCAD, draw circle and hexagon.

      We'll hit Enter on that. Close the loop. So we've encountered an error here. So that error is starting off with the angle points. I kind of figured this was going to be the a situation here. So we'll stop this program and go over some of the issues that are happening here.

      But it's having a failure generating the polyline based off of the angles. Likewise, it was also going to have an issue with this close command. If it hadn't failed here, it would have failed at the close because that would have tried to close the file rather than close the polygon. So I'm going to go ahead and reset the program-- reset the Lisp.

      Let's go ahead and try Copilot and see if it can provide us with a different answer. Oops. Let's go back to the Notepad-- copy our question-- paste that in. So far, this is giving us pretty much the same results.

      It is likewise trying to draw the polygon, but it is leaving out the closed function here. Instead, it is replacing it with a "C," which if everything else was to run, hopefully would exercise the close command inside the polygon function to generate that polygon. Let's go over and see what the results are here for Google Gemini. And while that's running, I'm going to go ahead and post this into Venus and come back to Gemini.

      So here, this function-- is it's defining the function a little differently. In this case, it is asking for dependent variables. So it is giving us the command information here where we are defining that. And it's asking for a little bit more user input with the routine rather than some of the automated functionality that was coming through our definition before.

      And then with Gemini-- or sorry, with Venus, here, we've got similar information. We're setting two points-- the radius, drawing the circle. In this case, it is telling us what those six points are, and giving us that information, then feeding that information into the polyline, having it closed, having it joined, and then zooming out.

      So just to see something a little different, let's go ahead and copy this code. Put it into our Lisp editor. Run that. And we're looking for circle and hexagon as our command-- circle_hexagon. Let's actually just copy this. It doesn't want to copy.

      So it is giving us an error on this function as well. Apparently, it is my fat fingers that are causing the problem here. So reset. So it's not fully functioning as much as everything else-- not fully knowing why, but it probably is more user error and understanding.

      But the idea to take away here is we are getting different results from the different AI's. So let's go ahead and see what we get when we have it try to enter in an x reference. So I have a different ask here. In this case, the question is, I need a routine that will load a specific x reference inserted at 0, 0 and a one-to-one scale when the routine is run.

      I'm asking this one to handle file manipulation, which is ultimately where we're going with the presentation and the other commands. So again, we're defining a routine-- in this case load xref. We're having a variable that is including a path. For those that understand Lisp, we would need to have double slashes for each of these, which indicates, again, why we need to be careful with some of the AI's.

      So it's going to get us about 75%, maybe more, maybe a little bit less depending on the project. So we still need to make sure that we're understanding our code a little bit in order to make sure that we're getting the results as necessary. So it's giving us insertion point of 0, 0, scale factor of 1, and then running all of that inside a command, and finally giving us a print statement with the information that we had requested.

      Going over to Copilot and pasting the same question-- while that runs, we'll push that into Gemini. And we will paste that into Venus. So Copilot-- similar name, slightly different x reference. Because we didn't specify a path, it's entering something generic that we would need to enter in and resolve ourselves. And then it's feeding the same variables as ChatGPT with the insertion point, the scale, and running that command.

      So looking at the Gemini function-- scrolling down to it-- so we have a very generic function just called load x reference and 0, 0. We only have one variable called x reference name. Since we didn't specify anything, it put in some placeholder information for that x reference name. Then it just runs the insertion to simplify everything.

      Moving over to Venus, we have likewise a very shortened routine with the x reference file, the x reference name, two variables there, and then going ahead and running the command. So what I'm trying to get with all four of these here is that we're getting some results. Some are going to be very similar to each other. Some are going to be very different from each other.

      It is still up to us in order to find out which one we want to start with and move forward with. Some people might understand one string of code a little bit better than another. But using all four here, we can start to analyze and pick apart what we need and hopefully get us going down the right path for the routine in question.

      So why did I get into AI here? How did I start all of this? So I had a situation at work where I needed to copy-- I needed to visit a client. And I needed to have some network resources loaded onto the hard drive of the laptop that I was using so that I could have those resources while I was working with the client-- generating some information and generating a series of code.

      So when I started working on using AI, I had an instance where I was copying-- needed to copy information from one project location on the network drive over to my C drive. We had a client that we needed to see, and I needed some of the library resources that were on our network. I first generated this routine in order to copy that information automatically within AutoCAD because it was a Lisp routine and didn't have much information on the library that I was copying over.

      The routine executed relatively quick. As I started doing more and more, and the library started getting larger and larger, I realized that this routine was taking longer than would be ideal if I was giving this to somebody else. Having a pause of a minute or so isn't that big of a deal. But if I had to copy hundreds of megs, or maybe even gigs of data, that amount of time is going to start kicking up into hours, which is unacceptable.

      So the idea that I had was, instead of having this routine in a Lisp routine, what if I could generate a Lisp routine that would execute an external file, have that file process outside of AutoCAD, and then could continue to do what I'm doing inside AutoCAD on a regular basis and just have it process here? So that idea was to create a batch file. Now, I'm old enough to remember DOS, but I haven't used many of the DOS commands for a while, so I wasn't fully-- my skills were a bit rusty on what that routine was going to look like. So I figured I would go ahead and use AI in order to help me with that.

      So we'll go ahead and take the routine here and copy that over into our AI. So for the remainder of this, I'm just going to focus on ChatGPT. Copilot is being very similar. And I think most people are aware of ChatGPT. I'm not using ChatGPT in any regards-- saying that it's better than the others. I'm just using it based off of market familiarity.

      So let's go ahead and ask the question, "I need a bat file that will copy information from a source location to a destination. I also--" Let's just have it ask the batch file first. So one thing that is interesting about AI is it is always evolving.

      So this is the first instance that I have seen a side-by-side comparison. I'll admit it's thrown me off a little bit here on why it's given me two responses. But looking at things a little bit side-by-side, we're effectively seeing very similar code. One is using xcopy. One is maybe annotated. They're both using xcopy. One is annotated a little bit more for if the destination doesn't exist in order to create that destination.

      One is pausing to keep the line open. Well, they both are. So there, we have an instance where it's given us some information. It's using the xcopy functionality here. Because we didn't give it a source location or a destination location, it has filled in generic information that we can then go ahead and fill in on our own. If you're taking snapshots of this and wanted to use this on your own, just make sure that you're editing these two paths before you try it out.

      I do know that xcopy was very much from the days of DOS, and that robocopy is now considered one of the more preferred methodologies here. So let's go ahead and replace the xcopy function with robocopy. So it's gone ahead and replaced that information. And this is a situation where as we learn more and more as programmers, we can say, hey, I know that yes, this function exists, but I also know that there's this other way of doing so.

      In some regards AI, is going to be like a child-- let's say a third grader. They some of the basics. They things that are effectively right or wrong. Maybe they don't know all of the rules. Third graders have a tendency to still kind of run out into the parking lot once we get out of the car. Maybe they're not looking both ways.

      So they still don't necessarily know all the information that we have as adults here. So teaching it is going to be part of what we need to do as programmers, and is where we start to grow as well. So by replacing this code, we're helping ourselves here and seeing what that destination is going to look like.

      I'm going to swing back over to my presentation here, because during the presentation, I felt that there was some information that was good to mention. So I had provided the question for the batch file. It had given me some information. When I had asked it to provide the robocopy, it had failed on this line here with the /e, and the copyall, and everything.

      When I ran it-- because I wasn't sure if it was going to run, and I wasn't very familiar with the robocopy. Fortunately, when it failed, the BAT file gave me some more information. And so it recommended that I change the line for the robocopy from being the copyall with other parameters down to a simple mirror. So this is another instance where we need to take a look at other resources. In this case, it's actually the help from the robocopy function built into the command line that is giving us the information.

      And so we can take that. In order for it to work, we obviously need to be providing it with the correct parameters. So I want to go ahead and mention that because it is some good information here to take with us. Oops, went one too far. Let's go back to our ChatGPT session.

      Once I got this to work, it worked quite well. I started to share it with a few others, and the downside was that all of us have been trained through the internet that if we see a pop up ad or something, we want to go ahead and close something that we didn't open. And so with this routine, one of the pieces of feedback that I got was that the command wasn't working. They weren't getting the information.

      And when I talked with the users and found out what was happening, the majority of the time, it was because the command window popped up on screen, and they went ahead and closed it, which canceled the copy function. So of course, they're not getting the information because the information didn't copy over. So from there, I realized that I needed to take this information, and I needed it to be in-- I needed it to happen in a format where I wasn't going to be seeing-- where the user wasn't going to be seeing any command window. It needed to be hidden, it needed to be silent-- whatever the proper terminology is here.

      So doing a bit of research, I found that the only way that I could do that made sense to me was using a VBS script. So let's go ahead and convert this batch file now to a VBS. Now, while I was writing this, VBS was definitely new to me. It was as though someone was speaking to me in Klingon. I had zero idea what I was looking at.

      So I heavily went through other sources of information, talked to co-workers, had them review a few things, but also took a look at-- relied on the online community with Stack Overflow and the various forums for Microsoft in order to piecemeal the information that was happening here. So understanding what the defined option-- the explicit option here was, seeing the variables for the source and the destination that was providing me that information. Then, it's going ahead and, in this case, creating a robocopy command, and then opening up a shell where it can run it.

      So having all of this was quite helpful. And then it does display some message boxes. The only input that we're getting here are these message boxes when it has been successful or when it has been failed-- or when it has failed. So if I wanted it to be 100% silent, regardless of the success or failure of it, I would probably remove these message box items here and just have it execute.

      If I didn't care about the success, I would just remove the success and have it only display on a failure. And maybe I would change that failure code to say, hey, this was generated by Steffinger-- give him a call in order to troubleshoot and resolve the problem here. So this is where I say that the learning capabilities here with AI can be absolutely fantastic. In the course of just a couple of years, I went from doing all of my coding exclusively inside AutoLISP to starting to utilize other aspects, starting off with a batch file and continuing over to a VBS.

      Now again, we haven't run this. I don't want to run this because we don't have any paths defined, so we know it's going to fail here. But what the AI has done is given us some-- it's given us a starting point. And that's what we need to realize, is the AI is not necessarily going to be 100% the answer.

      We need it to handle that creation for us-- get us to a starting point that we can go ahead and finalize the process ourself. When we're starting off, we will still need to use other resources. If you're new to AutoLISP, while you're using AI, I would have the help file open for AutoCAD. That's on the website, and you can go through the functions there.

      If you have another coworker that also does some programming, ask them. Have them take a look, and maybe troubleshoot, and things. Your coworkers are on the same team as you, literally, so why not utilize that resource?

      And then for other languages, there's other websites out there. I mentioned Stack Overflow. That has been tremendously helpful to me as a tool to learn and understand some of the various languages as well. Using AI, I have also started to get a little bit into the .NET, the C++, C-Prime, C# programming, as well as a little bit of .NET. But that information is so new to me that I was definitely not going to share it in a presentation like this.

      So at this point, that takes us to the verifying and the quality control for what we're doing. So we've gone ahead-- we've had the AI generate the content. We've used external resources to go through and do things. And maybe it functions. Maybe it gets up to a certain point and then fails. So that's going to happen.

      Depending on the editors that you use for some of the programs, it might tell you-- if you're using AutoLISP, it will tell you where it's failing, and that can be helpful. Obviously, in something like a batch file or a VBS, I'm not aware of any editors that will highlight where that problem is. We start having to go through line by line in order to get some of the results.

      So that quality control is going to be important. When you're learning, when you're trying something, don't just immediately-- in this case with the moving of files, don't have it try to copy everything at once. Give it a small sample set of information. Can it copy one file or two files over. If that becomes successful, then slowly start building that up until you have your full set and you've been able to test it.

      If you're finding out that the process is taking too long, as you're starting to add more information, well, then go back to the AI and ask if there's other suggestions or maybe even other routines out there that will-- or other languages out there that will speed up the process. Ultimately, what we're trying to do is get you to learn so that you can become a better resource for your partners, your team, the firm that you work for.

      So thank you very much. I hope that all of this has been very well-received. Continuing with the quality here, we want to make sure that we're adding comments, because if we go back in a few weeks, or months, or days-- maybe even a few years-- somebody else takes a look at-- we want to make sure that we've got some comments that are in there-- that we understand what's happening so that we can troubleshoot and say, it's getting to this point or not getting to that point-- what does this code actually mean?

      So thank you very much. I hope that this has been an informative presentation. And thank you for listening and paying attention. Have a good day.

      Downloads