Parameter value has to take next even number

Parameter value has to take next even number

Anonymous
Not applicable
1,729 Views
8 Replies
Message 1 of 9

Parameter value has to take next even number

Anonymous
Not applicable

Hello Folks 

 

I have bush having parameter called OD ,  this OD has some expression and the value of this OD=21.366 like this 

 

I want a code to bias this OD value to next even nuber 

I mean code has to automate the value to next even nuber , above said example  OD=22 

 

Please help me out 

 

-

Kiran Kori 

-Smiley Happy

0 Likes
1,730 Views
8 Replies
Replies (8)
Message 2 of 9

VdVeek
Advocate
Advocate

Kiran, when you create a new Userparamter with this equation you get the next rounded number:

 

ceil(OD / 1 mm) * 1 mm - where OD=21.366 is the name of your parameter gives your 22 mm (rounds to the ceiling)

floor(OD /1 mm) * 1mm gives you 21 mm (rounds to the floor) and

round (OD / 1mm) * 1mm gives you the nearest rounded value.

 

when you use floor(OD / 2 mm) * 2 mm you get the rounded even number 20mm.

 

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
0 Likes
Message 3 of 9

Anonymous
Not applicable

 

 

Hello Rob

 

Bushdesign.PNG

 

 

In this above shown bush design ,  my Inventory shop always have even number Small_OD bushe sizes 

 

Please give me iLogic code to make Small_OD value always should be even number of next increment 

 

Small_Dia=15.46

Small_OD=Small_Dia+6=21.46

 

But i want iLogic code to make this 21.46 values should be next even number say 22

 

Please help me out

 

 

Kiran 

Smiley Happy

 

0 Likes
Message 4 of 9

VdVeek
Advocate
Advocate

Why do you want to use iLogic for this task? And where do you get the Small_Dia value from?

It's posible to directly use the ceil, round, floor options within a dimension, see screenshot. Please have a good look at the space used in the formula otherwise it's not working.

When you want to use iLogic: in the Math section of the snippets there are also the ceil, round and floor functions explaned.

Rob.

round.PNG

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
0 Likes
Message 5 of 9

TONELLAL
Collaborator
Collaborator

You can use this :

Create 3 user parameters in Inventor : val, test, final_val, all in cm, where val is the original value, test is an intermediate test value and final_val is the result

test = round(ceil(val) / 2 nd) - floor(val / 2 nd)

final_val = ( floor(val / 2 nd) + test ) * 2 nd

 

Result obtained :

val = 5 --> final_val = 6

val = 5.3 --> final_val = 6

val = 8 -->  final_val = 8

val = 8.2->  final_val = 10

 

2015-01-15_14h39_54.png

 

 

Hope this help !

 

Alain

0 Likes
Message 6 of 9

VdVeek
Advocate
Advocate

Alain, you made a complicated formula. What is the benefit of this way compaired to the option i gave?

And there are some errors in your formula's because of a unit type mismatch, see also the red color in the parameter screen. You use the non existing "nd" unit.

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
0 Likes
Message 7 of 9

TONELLAL
Collaborator
Collaborator

Effectively, I misundesrtood your answer with the drawing...

For the red color in the formula, it's because Inventor use nd by default, I have not replaced with mm.

So your answer is the simple way, mine is the secret one ^^.

0 Likes
Message 8 of 9

Anonymous
Not applicable

many Thanks rob , it worked.

 

 

In this below image, I want to make highlighted parameter in to roundfigure.  please provide me the similar kind of code  

 

 

sdfdf.PNG

0 Likes
Message 9 of 9

ravikmb5
Collaborator
Collaborator

Use isolate Function

for unit replace

Please mark this response as Problem Solved if it answers your question.
----------------------------------------------------------------------------------------------
Ravi Kumar MB,
HP Z220 SFF Workstation
Autodesk Inventor Certified professional 2016
Email: ravikmb5@gmail.com





0 Likes