New Part CATIA macro tutorial
Learn how to make simple but very useful CATIA macros.
First of all making new part in every CATIA session is like must to take action. Certainly using integrated new part option is not very acceptable. It is due to many reasons. Also defining a name of part is not practical. Even more you must save this file to folder and so on. As a result I decided to show you how to make new part CATIA macro in this tutorial.
Recording New Part CATIA macro
Best and easiest way to make new part CATIA macro is to record one. So after recording you can edit it. Therefore let’s record this macro then. So we got this code.
Certainly this is very simple code to understand. If you want to read evenmore about declaration of variables you can do it on this link. First of all, very important line for us in this macro is “Set partDocument1 = documents1.Add(“Part”)”. This line code defines making new part and part name. Also let’s record saving this macro in folder.
Also we need to record one more macro for changing the name of this part.
This line of code “Set product1 = partDocument1.GetItem(“Part5″)” is very importat. We don’t want “Part5”, because it will work only for that part.
Editing New Part CATIA macro
As result we have three macro codes. So let’s combine them into one new macro. Consequently you can see we have some same lines in these three macros. So we can add last two lines of code from second macro to the first. In contrast for the third macro we must make a change. So we must change “Part5” with Partdocument.part.name.
Hence try to run this code now. It will make new part and save to the location. In my case location is “C:\Users\Me\Desktop\New folder\Part1.CATPart”.Finally we want to edit that part name. Due to we will use input box. So we will ask user to input part name information for this new part CATIA macro.
Certainly very good practice is to previously define name profile like.
Therefore user need to copy this profile and just edit it. As a result you will get very organized part names. Finally we just need to change two more things and we got new part CATIA macro.
Final code for New Part CATIA macro
Final usable code for New Part CATIA macro.
You can see also my video tutorial, how to make this macro.