Simpe free CATIA macro
Simple free CATIA macro
“Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.” – Thomas A. Edison
In this post, we want to show you a good way to use simple free CATIA macro. Certainly, at the same time we want to encourage you to make your own.
Introduction
Well, the known proverb is that a journey of a thousand miles begins with a single step. From this proverb, we can conclude that even the longest and most difficult ventures have a starting point, something which begins with one first step. Basic and simple macros are the first step in macro programming. Above all, we hope that this post will help you with ideas for simple macros and give you some basic info and knowledge. At the same time, you can notice that even these simple macros can do great things. On the other side, all of these simple macros are integrated into advanced ones. Hence best practice is to learn and understand short macros and then try to integrate them into advanced ones. In this macro there are 4 actions: define in workobject, update, save and close part. All of these simple actions are in any sort of macros.
Writing the CATIA macro code
If you don’t know where to start, the best start point is to record a macro. After that, you need to understand it, and at the end to write some changes.
Language="VBSCRIPT" Sub CATMain() 'Declaring variable for active document, in this case it's part document Dim partDocument1 As Document Set partDocument1 = CATIA.ActiveDocument Dim part1 As Part Set part1 = partDocument1.Part 'Our first goal is to update part part1.Update 'Second is to define in work object, you can see this coda, once you have it, you can use it as many time as you want Dim bodies1 As Bodies Set bodies1 = part1.Bodies Dim body1 As Body Set body1 = bodies1.Item("PartBody") part1.InWorkObject = body1 'Third is to save part partDocument1.Save 'At the end close part partDocument1.Close End Sub
So you can just copy and paste this code. Also, you can download the VB application for a simple free CATIA macro. I prefer to use this code from the script because I like to put a shortcut on this code so it’s very easy to run it. Rather if you don’t know how to do it you see more about it on this CATIA shortcut post because it is very easy. Also, you can see how to do it at the end of this post in the video for a simple free CATIA macro. On the other hand, VB application has the advantage to activate any option, use only save, update or any combination.
Finally, you can download it for free and use it. If you have any issues feel free to contact me.