Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic rule to make all my number in odd number

13 REPLIES 13
Reply
Message 1 of 14
ChristinaForest
1367 Views, 13 Replies

ilogic rule to make all my number in odd number

I dont no in english if odd number is the right word but i want to make all my number to 1, 3, 5, 7, 9, etc,....

 

Thanks for your help 🙂

13 REPLIES 13
Message 2 of 14
mehatfie
in reply to: ChristinaForest

Hi sergelachance,

 

I'm not exactly sure what numbers you are trying to change? 

 

And yes, Odd Numbers is the correct way of saying this.

 

Regards

Mitch

Message 3 of 14
ChristinaForest
in reply to: mehatfie

Thanks Mitch for your reply 🙂

 

Do you have a exemple of rule?

Message 4 of 14
mehatfie
in reply to: ChristinaForest

Hi sergelachance,

 

Please use a translator to understand, or what language do you speak?

 

I am asking a question about what numbers you are making odd.

 

Regards

Mitch

Message 5 of 14

Sorry for my horrible english, i'm french Canadian 🙂

 

I just want  to change with ilogic when my parameters number is even same to 0,2,4,6,8,etc,... change to odd number same to 1,3,5,7,9,etc,.... what is a right rule for that???

 

Thanks again!

Message 6 of 14
mehatfie
in reply to: ChristinaForest

Hi sergelachance,

 

This is a simple rule that will check for what you have asked. I'm not sure of your true application, but for a single parameter this should work.

 

The code is dividing the parameter by 2, if the remainder is not 0 (ie. it is not divisible by 2 into a whole number), the code will add 1 to the parameter.

 

 

------------- Code ----------------------

 

If (Parameter("PARAMETER_NAME_HERE") Mod 2) <> 0 Then
     Parameter("PARAMETER_NAME_HERE") = Parameter("PARAMETER_NAME_HERE") + 1
End If

 

--------------------------------------------

 

 

Regards

Mitch

 

Let me know if it helps.... Kudos if it works!!!

 

 

Message 7 of 14
ChristinaForest
in reply to: mehatfie

Hi Mitch 🙂

 

the rule work but for what add 1 if the parameter is not dividing by 2???

 

even number.PNG

Message 8 of 14
mehatfie
in reply to: ChristinaForest

Sergelachance,

I'm sorry, for some reason I was thinking the opposite and you wanted even numbers.... I have no idea why I was thinking this.

Change the code as follows:

Replace: "<>"

With: "="

This will instead mean, if the number DOES divide by 0 and has NO remainder (ie. an even number) then add 1 (to make it odd).


Regards
Mitch

Let me know if it helps... Kudos if it works!!!
Message 9 of 14

Thank you very much for all Mitch!

 

i try that later 🙂

Message 10 of 14

i try but same probleme 😞

Message 11 of 14
mehatfie
in reply to: ChristinaForest

Hi sergelachance,

 

I'm not quite sure I understnad what the problem is. The code I provided adds 1 to an even number in order to make it odd. You could also MINUS 1 if you'd like in order to achieve an odd number as well.

 

What confuses me with your code is that you have 2 different parameters being used.

 

Why is it:

 

("TROUSTAB" Mod 2) = 0 Then

     "QTETROUSTAB" = "TROUSTAB" + 1

 

 

 

Shouldn't it  be:

 

("TROUSTAB" Mod 2) = 0 Then

     "TROUSTAB" = "TROUSTAB" + 1

 

 

Regards

Mitch

 

Let me know if it helps... Kudos if it works!!!

Message 12 of 14
ChristinaForest
in reply to: mehatfie

Hi Mitch, i try your new rule but dont work again 😞

 

even number 2.PNG

Message 13 of 14
mehatfie
in reply to: ChristinaForest

Sergelachance,

 

That was NOT a new rule,  you must keep the OLD rule but replace the parameter name

 

 

If (Parameter("TROUSTAB") Mod 2) = 0 Then
     Parameter("TROUSTAB") = Parameter("TROUSTAB") + 1
End If

 

Message 14 of 14
ChristinaForest
in reply to: mehatfie

OK, Thank you very much Mitch for your time 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report