Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Rule in CATIA V5 - odd/even number

Status
Not open for further replies.

Rooooobeeeert

Automotive
May 9, 2016
2
PL
Hi.
I need some help with Knowledge Advisor module.

I am trying to make a rule for odd-number and even-number.

Here is my way of thinking:

If X/Y = even-number - I dont know how to creat this part, the result should be Integer but I can make a "CHECK" for that
{
`Construction Elements\Offset_X\Offset` =0
}
else
{
`Construction Elements\Offset_X\Offset`=Y/2
}

I saw some function in c++, but it doesnt work for Catia, can You help me ?
"if ( integer % 2== 0 )

// if the integer when divided by 2 has no remainder then it's even.

cout << integer << " is even "
<<endl;
else

// the integer is odd"
 
Replies continue below

Recommended for you

you can use mod function for that.

mod((x/y),2)==1) will be true if (x/y) is even
mod((x/y),2)==0) will be true if (x/y) is odd



Eric N.
indocti discant et ament meminisse periti
 
Thanks a lot, it works. Here is my code, maybe it will be helpfull for somebody

If mod((X/Y),2)==1

{
`Construction Elements\Offset_X\Offset`=Y /2
}

if mod((X/Y),2)==0

{
`Construction Elements\Offset_X\Offset`=0*1mm
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top