Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create an if else rule CATIA V5

Status
Not open for further replies.

Sendoacf

Chemical
Jun 10, 2022
8
0
0
ES
Hi,
I would like to write a rule for my CATPart which can solve my problem
I have a Body with several Pockets, lets name them with a,b,c,...
The point is that i want a rule which if i write "a" in a Parameter the "a" pocket is active and the rest of the pocket gets disabled, if i write "b", the "b" pocket is active and the rest of them are desactivated,...
Actually I have smthng like this :
if LETRA=="A"
{
LETRA_RESTA\A\Activity =true
}
else
{
LETRA_RESTA\A\Activity =false
}
if LETRA=="B"
{
LETRA_RESTA\B\Activity =true
}
else
{
LETRA_RESTA\B\Activity =false
}
to the infinite with the rest of parameters. But I would like to know if i can simplify this and dont need to write all of them for like 20 diferent parameters.
Thank you and sry for my English^^
 
Replies continue below

Recommended for you

But that´s rule or what? Sorry but im new in this and i cant understand u :(
As i said i have a paremeter (LETRA) where u write a letter, from A to Z, then i haave a PartBody with several pockets named from A to Z. I want to make a relation between the string parameter (LETRA) and the .activty of my diferent pockets so i write for example "c" in my parameter and all the pockets.Activity except the one named as "C" are desactivate. And the same for the rest of letters, if i write "x" in my parameter LETRA my PartBody should update and desactivate all the pockets except the one named as "x".
IDK if im explaining it good, btw thank you^^
 
Sorry buy i dont really understand the video, as i said im really new in programming rules or similars and im actually starting to learn the basics of "programming"
 
In a rule, if you have a list of items, you could loop through the list. It is possible to create a list of features using the Query command. Then loop through the list matching the name.

Code:
let mylist(List)
let letra(String)

for pocket inside mylist
{
     if pocket.Name() == letra
     {
          pocket\Activity =true
     }
     else
     {
          pocket\Activity =false
     }
}

 
Hey thank you, i think i understand how to do this. But i dont know how you can create a list of items. Is that another rule or macro? Or how can i do a list?
 
Status
Not open for further replies.
Back
Top