New body CATIA macro tutorial
This post is about basic CATIA programing knowledge.
In this tutorials section I will post simple macros, so you can learn some basic stuff.
This new body CATIA macro code is very simple so you need to understand it first. Sub CATMain() is main function, it always go on the first place of the code, in the end you have End Sub for end of that main function. Inside of this function you have code for making new body. Dim is used for declaration of variables. You need to declare variable before you use it. After declaration you need to set value for the variable.
In my case partDocument1 is declared as Document, but it can be named differently. You can give names like TestDocument, Test or whatever you want to set. Value of variable partDocument1 is CATIA.ActiveDocument, it means that this variable is active document. It can be any active document like part, product etc.
In the same way we define part1, first we declare it as Part and then we set value for part. Part1 is CATIA.ActiveDocument and in the same time CATIA Part. Here you can see that tkind of active document is very important. You will get error If you try to run this macro in the product. In the end we declared body as part1.bodies. Also u can write just one declaration like bodies1=CATIA.ActiveDocument.Part.Bodies
At the end when we understand this recorded new body CATIA macro code we can change if for a bit.
We made just simple changes, we use simple for loop and name property for the body. In this case we can’t control this for loop, to do that we must use InputBox.
So nothing is changed, we still getting 10 bodies, we must say our Loop to go to that input number.