Use Chat GPT to create commands and automate tasks in AutoCAD

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I don't know anything about autolisp which is a programming language that you can use to create programs or just commands in aicad and still I managed to make a three-point parallelogram like this one using chat GPD which created the program for me I also don't know much about writing line type codes which is again a different kind of code in aad and still I managed to make this line type completely using line type code using chat GPT I also don't know anything thing about writing macros in aad which is kind of like series of commands that will run one after another and still I managed to create a new AutoCAD tool that will audit the drawing Purge it save it and also close the drawing and of course I did that using chat GPD so in this video I'll show you how to do just that even if you don't know anything about these codes macros and all these other advanced stuff you can do that using chat GPD so with that that let's get [Music] started all right so for our first example I'm going to create a parallelogram using Lis routine and we just want to provide the first three points and we want AutoCat to figure out the fourth one all right let's do it using chat GPT so I'll open chat GPT here it is if you don't have a free account go ahead create it and then login and you'll reach this kind of prompt screen now here you just need to be as descriptive as you can and just enter the prompt so in my case I'm going to type the prompt create a foursided polygon using lisp where the user is prompted to provide the first three points and the fourth side is on the side of the first point so that the final shape makes a par okay this is the prompt that I came up with I'm going to press enter and let's see the result and here is the result so let's copy this code and I'm going to Simply create a text file so new text document double click this and let's copy and paste this now let's save it so I'm going to click on save as and I'll call it a. LSP so LSP is the file format for list routines so click on Save and we have this a. LSP file all right let's open aad and I'll keep this window quite small so that we can drag it and drop it here now after dropping it well we've got a problem it looks like we have an error here right out of the box which is error no function definition format so let's update the prompt it's showing error the lisp is for AutoCAD now we have the updated one so copy this code and now let's paste it here file save as and I'm going to call it b. LSP our second version click on Save and let's try it so drag it drop it and here is the command that will activate this make parallelogram all right so let's now try that make p a r and there we are the command is there press enter and we have the prompt enter the first point then the second point and the third point there we are we have got this now the command is still active but you can press escape and there it is so it's as easy as that now if you want to repeat this command all you need to do is just type that make parallelogram press enter and let's make one more parallelogram here there it is press Escape escape this command now you using this you can also create several iterations of the similar kind of command or you can create in batches and combine all the list proteins to create a really big command for example if you want to create the elevation view of stairs with the prompt that will just ask you for number of risers Treads number of steps or maybe you can just specify the total floor height and it will automatically figure out the number of steps and so on and there are also several other use cases now here is the Second Use case now consider a situation where we want to audit our drawing we want to purge it and then we want to save it so these are three different tasks that we want to do using just one command and we can obviously do that one by one but we can automate it using macros now if you know how to use macros which are basically series of commands that you can write in aad and aad will execute it then that's great but if you don't know then you can ask chat GPT to create the macro for you which we are going to do so here in the chat GPT I'm going to ask it to create the macro so all right so here it is create an aat command macro that will audit the drawing Purge it save it and then close the drawing let's see what it's coming up with all right so this is the plain text version of it with the comments which we don't want so let's just change it a little bit create it in one line in one line we just want a one liner of course we don't want it in all these lines so now we have the clean version we don't have all these comments okay so we are done now all you need to do is simply copy this and paste it but we have a problem here so in this case it may show some prompts for the user which we don't want but still nonetheless I'm going to go with this and then we'll fix the prompts later so let's go to aicad now click on new and here we're going to go to cui this customized user interface is where we can create our new command you can also go to manage and click on cui interface here now here we have this star icon just click on it and that's going to create a new command called command one let's rename this so you can rename it here as well if you want and I'm going to call it power save okay that's the name of our new command and this is where we will add the macro so I'll just delete this or maybe I'll just click on the ellipses and right here we'll add that macro which we copied from chat GPT now press escape and just press backspace just to remove that extra space character click okay and we have this added now we just need to ensure that it is added somewhere in the user interface to make it work but before we do that we also need to add an icon which is completely blank so maybe I'll scroll down this list of icons and from here I'll select an icon for this it looks like this this tick is going to work so I'm going to select this and if you are satisfied with this great if not you can change it but I'll stick with this all right apply so this is done now let's add this power save maybe on the quick access tool bar which is this bar here so I'll expand this I'll expand the first bar then I'll drag this power save and I'll add it here so power save is added here now it looks like from my previous test we have this test macro so I'll just select it and and remove it so now we only have this power save apply and okay done so we have this power save added here now let's make something here let's just first save it somewhere on the desktop maybe so sample all right this is saved all right and now we are modifying our drawing we are making some changes and then we want to power save it so click on this and there it is as you can see it's prompting for for Purge which we don't want we obviously want it Purge but automatically so let's go to chat GPT and tell it that we don't want user prompts don't prompt for user input so there it is now we have a completely different command here and hopefully this won't prompt so let's copy this code and let's modify it in the cui so go to cui and here we are we have got the power save and here is the macro and just copy and paste it here click okay and apply and okay again all right let's test it so I'll click here and it looks like it is still prompting so let's just specifically tell it that it should stop prompting for Purge okay so now let's see what it's going to come up with okay so we have this modified version of it let's copy this and once again let's go to cui and power save and here we're going to save it all right click okay and apply and okay all right let's test it one more time so I'll click on power save and it still prompting all right and here's the updated version so once again now there are a few back and forth iterations that you just need to do and this is completely normal and that's how it is supposed to be done so you won't get the right result the very first time but after a few iterations you will eventually get there all right so after several iterations as you can see there are few more prompts that I added I've reached this one which I'm sure is going to work because I tested it so let's now copy this and let's modify this so again I'm going to go to cui and power all right and here we are so let's copy paste this remove the space character apply this and close it all right so here we are now let's run it so there it is it is it's working perfectly now it not only ran the audit Purge and save command but also it closed it finally so if I let's say want to work on this drawing even further I'll maybe make it like this and then again instead of saving it normally I'll simply click on my power save button and it's going to run all these commands for us and it will also close the drawing so that's how you can do it now let's look at the third example so so here we'll make a custom line type basically we'll make line type that represents gas pipeline and for that well we'll create line type code in chat GPT so let's give it a prompt so here I'll simply type this create a line type code for aad line type that contains a line of length 5 unit then gap of one unit then the text G and then again a gap of one unit so that's how the line type type is going to look like which is pretty much like this so I'll press enter and here is the code now this is certainly not the right kind of code that I'm looking for so I'll just click on regenerate now if you want you can try this exact same code but I know that this is not going to work so I'll just regenerate it again and this looks more like it but still I'll regenerate it because we can't just have it in just two lines so I'll regenerate it and I'll regenerate it again now this is more like it so this is the code that I think should work by the way I've explained all about making custom line types using Express tool and line type codes in this sourcecad course it is linked in the description down below and also there is a ton of valuable information about making custom hatch patterns importing it exporting it from one aad drawing to another and once again it's in the same course which is linked Down Below in the description in my case I am already regenerating it just by looking at the code but you can give it a shot you can try the first five iterations of this code and try if they're working or not if not you can ask chart GPT to make the corrections and then you'll have the proper code in this case it's not very much kind of a fullprof code yet but let's see if it's working or not so I'm going to go to this text document and I'll paste it here and let's save as on desktop I'm going to call it a. Lin now Lin is the line type file so save it now let's go to aad and here I'll load that Lin file so I'll go to the drop down other click on load and right here I'll select the Lin file which is on the desktop so select and open and it looks like we now have that line so click okay and the line type is loaded as well so click okay and we can now apply that line type on any object so maybe on this line I I'll select it and I'll apply the line type there it is not only that you can even change the scale of this line type so you can select it right click go to properties and here I'll change the scale to maybe 0.4 and there we are so it's updated so that's how you can create custom line type now once again if you are not satisfied with the way it looks for example the text is not centered then you can ask chat GPT to recreate it with the corrections so after a few iterations you'll get the proper code that's going to work exactly the way you want and of course you don't need to learn this line type code or hatch code for making these custom objects so that was all about using AI tools like chat GPT to do things in AutoCAD that actually won't be possible without knowing all about autol Lis macros line type codes hash codes and so on now let me know in the comments down below if you used chat G P to make your AutoCAD workflow easier also what should be the next video you want to see on sourcecad share it in the comments area and I'll see you in the next one take [Music] care
Info
Channel: SourceCAD
Views: 15,320
Rating: undefined out of 5
Keywords: chat gpt in autocad, ai in autocad, autocad chat gpt
Id: YWe7KjlirMQ
Channel Id: undefined
Length: 14min 19sec (859 seconds)
Published: Wed Nov 15 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.