CATIA macro selection
CATIA macro selection
CATIA macro selection is a very important topic and concept to learn when automating CATIA processes.
CATIA macro selection is a very important topic to learn when automating processes. It is ground in every macro. Hence for every action in a macro, you need some kind of selection. There are single and multiple ones. There are also two ways to select elements. So those are user selection and search by name. Hence when you have the selection you want to use that for loop control. For example, if you select 4 bodies you can iterate 4 times. So in this post, we will show you more examples of selection usage.
Example 1: Change color
Comments are inserted in code. So you will follow and better understand it. Let’s start with a simple selection code so you understand it first.
Example 2: Single selection for new add
In example 2 we want to use CATIA selection for selecting the body. We want to add it to another body. For this, we will use a simple selection. So it means that a user will be available to select only one input. As a result, we should decide which selection we need for our code.
If you want to test this CATIA macro code you can just copy it. So you can try to use an input box to set and add a name for the body. You can watch my video tutorial to understand better.
This is a preview of the automation file. This file can help you a lot. So in this file, you can find everything you need.
Example 3:Multiple selection for new add
This macro is very similar to the previous one. In contrast in this, we want to use multiple selection.
Example 4: CATIA macro selection with search
Also in the next example, we want to show you how to make a selection with a search option. We will not comment on the same lines. Rather we will different ones.
This search option is very powerful when you define some basic names. Also, it’s very easy to connect with powercopy. If you want to read more about that go to this link.
You can also read more about selection on those links.
6 thoughts on “CATIA macro selection”
First of all thank you for your website it is really interesting and very helpful.
I’m a student and a beginner in VBA Catia and I have a question: I’ll try and explain exactly my situation
i have a list of part numbers in excel : i succeed in connecting that with catia
now i want that for each cell of my range i call a macro. i have put all the cells in an array and i’m trying to code the following in a loop:
for each cell value:
1-look in the catia tree if it’s present
2- if it is call my macro: here the macro is to extract properties for each partnumber call walkdowntree (myProduct)
i don’t know how to link each array value to the myProduct to run the macro
3-if not msgbox: partnumber does not exist
Thank you in advance for any ideas or help
It will be appreciated
Hello Rih, thx for the nice words. In the beginning, I want to encourage you to go with VB, not with VBA. VB is much easier, more advanced and has many more options.
I didn’t figure out what is the main goal of your code? Do you want to get properties of those parts from the excel list? If you want that, then you can sent back those values in excel for each iteration??
Is this some sort of stocklist or something else?
Hello, Thank you for your answer
sorry i didn’t explain well what i need
well what i did for now is using the catia vb editor and i created a userform to ask the person for the list of the products that we need to extract the BOM for. what i managed to do is have a first button that will create a new excel file and ask for the listing.
then using another button it will launch a macro that will for each number listed extract the Bom and store it in an excel file. I couldn’t do the loop, i tried with putting only one iteration
and i couldn’t print the BOM
for the excel file i needed to be:
Product number | Reference | QTY
i don’t know if you can help me, i’m willing to send you what i did by email?
Hello, yes now it has more sense. How a person will make that list, by selection or? I can help you ofc if you want I can make VB app to do that. Also, I can check what did you do, and give you some suggestions. In both cases, it will take some time for me to do that so it will not be free, unfortunately :(. Harun
Can you send me a message in private with the price
So we can discuss this
Is it achievable in 7days?