Change parameter CATIA macro
Introduction
First of all, in this post we want to write about the connection between CATIA macro and parameters in the tree. So there are a lot of options in this direction. One of the possibilities is to have full control of your model with macro. Here we want to demonstrate some basic, but you will get the idea.
Certainly fill stock-list parameters with CATIA macro is our focus. Why talk about this subject “change parameter CATIA macro”? So every model has some kind of stock-list. You need to fill those parameters every time. Rather there are a lot of parts with the same parameters. Also when you work as a team, you need to have same parameters for the same parts. For example, on trim dies, you have trim steels, and a lot of colleges will have them too. Hence best practice is to set those same parameters on all dies.
It is a perfect time to use the macro for this action. So let’s write some code for change parameter CATIA macro.
Writing macro code
This is just a basic idea, so you can do a lot more. Our code will fill just a few parameters, like material, info and example for dimension. We have in the tree three parameters with names: Material, Info and Dimension. Consequently, we want to set values for these three parameters.
Language="VBSCRIPT" Sub CATMain() 'This macro will work only in part Dim partDocument1 As Document Set partDocument1 = CATIA.ActiveDocument Dim part1 As Part Set part1 = partDocument1.Part 'We must to declare parameters Dim parameters1 As Parameters Set parameters1 = part1.Parameters 'Our first parameter is Material Dim strParam1 As Parameter Set strParam1 = parameters1.Item("Material") 'Value for material is "1.2358" you can put any material here strParam1.Value = "1.2358" 'Second parameter Dim parameters2 As Parameters Set parameters2 = part1.Parameters Dim strParam2 As Parameter Set strParam2 = parameters2.Item("Part1\Info") strParam2.Value = "H 60+2 HRC" Dim parameters3 As Parameters Set parameters3 = part1.Parameters Dim strParam3 As Parameter Set strParam3 = parameters3.Item("Part1\Dimension") 'For dimension we just make profile input strParam3.Value = "XX x XX x XX" End Sub
Furthermore, this macro will only fill these parameters if they exist.
Dim strParam1 As StrParam Set strParam1 = parameters1.CreateString("", "") strParam1.Rename "Info.2" strParam1.Value = "Text"
This part of code will make new string parameter and and value “Text”
Even more, see the video for more info.
As you can see in the video we demonstrated application with these basic macros. Therefore this application is very useful and saves a lot of time. It solves problems with a different profiles of parameters in every part and model. So if you are interested to buy this part of the app please contact us.
Check my other tutorials https://catiavbmacro.com/category/tutorials/, download some free macros https://catiavbmacro.com/category/free-macros/.
Not working catia v5 r19
Hello, what macro did you try?
There is huge possibility that some doesnt work on older versions. I test all macros in v5R26.
Can you tell me what did u try so i can check it?
Try color palate, that one must work.
All the best
Hi, can help me to find gap between two parts or two cast part??
for example, if we take shoe and cam in die design, if there is no clash between them but they have o mm or very less gap(5mm to 20mm) between them.
regards,
Hello, easiest way to find it is with clearance option in clash. More advanced option is with Edit Distance and Band Analysis tool.Second one is perfect option for your needs, it will find anything between two parts.
How change name for set parameter with macro??
Hello, chech this macro and code
https://catiavbmacro.com/2018/08/12/change-name-catia-macro/