Lego CATIA macro
“For me stories are like Lego blocks. If I don’t put one down, I can’t put the next one down.” Om Malik
This is new Lego CATIA macro application for making Lego blocks and inserting them into product. We have one more post about Lego block maker. But in this post we have different approach. In first post we make everything with macro, like first we make pad, after that pins and so on. Hence in this post we will not do any modeling, just change few parameters. All modeling was done in part with rules. So you just need to create some simple rules. Because of that we have two main controlling parameters, pin and row number. And these two are connected with the rule.
if Number_of_row == 2
if Number_of_row ==1
First specific case is when number of rows is 2 then block width is 15.8 and when is 1 then is 7.8.
if Number_of_pins ==2
if Number_of_pins >2
In second example we want to have pattern when number of pins is more than 2. So you can activate or deactivate elements inside the tree.
You can see all of these in the part, we will put link for download.
We use this picture to make model for Lego block.
Writing macro code
Steps in this CATIA macro:
1. Make selection of product
2. Make newFrom from base part
3. Change parameters using inputBox and rules
4. Save part to the location using inputBox
5. Add part to the product
It’s very important to make these simple steps for every macro. So you can go step by step, when one is working you can go to the next and so one. It’s very hard to write full code at once and there can be a lot of errors.
Maybe you don’t need this Lego CATIA macro, but you can learn a lot from it.
1. How to make multiple selection and how to use it in code
2. How to make NewFrom
3. How to change name of part and save it to location
4. How to control part parameters from CATScript
5. How to use InputBox(user inputs) to control if statements
6. How to add part to the product
Using this example you can easy make CATScript for inserting base part in your model. We think that’s very good practice.
You can download it for free and use it.
If you have any issues feel free to contact me.