Ilogic not working, what's wrong with my code?

Ilogic not working, what's wrong with my code?

corey_danielson
Advocate Advocate
190 Views
1 Reply
Message 1 of 2

Ilogic not working, what's wrong with my code?

corey_danielson
Advocate
Advocate
The .752 x 1.022 x .375 and the .752 x 1.022 x .75 do not work. Everything above
and below work perfectly. I have a form set up. I pick ID, OD, and LENGTH. When I hit
apply, the correct part number and description show up on the form. The dimensions of the part change
for every option except for those 2. When I select either of those 2, the dimensions update,
the part number updates, and the description is blank. The other 38 bushings work perfectly
with the description updating. Any ideas?


'======================================================================
If ID = .752 And OD = .877 And LENGTH = 1.25 Then PART_NUMBER1 = "McMASTER 6391K208" SHAFT_DIA = "3/4" HOUSING_OD = "7/8" DESCRIPTION1 = "OIL EMBEDDED BRONZE BUSHING 3/4 ID X 7/8 OD X 1 1/4 LONG" End If '====================================================================== If ID = .752 And OD = .877 And LENGTH = 1.5 Then PART_NUMBER1 = "McMASTER 6391K207" SHAFT_DIA = "3/4" HOUSING_OD = "7/8" DESCRIPTION1 = "OIL EMBEDDED BRONZE BUSHING 3/4 ID X 7/8 OD X 1 1/2 LONG" End If '======================================================================= If ID = .752 And OD = .877 And LENGTH = 1.625 Then PART_NUMBER1 = "McMASTER 6391K372" SHAFT_DIA = "3/4" HOUSING_OD = "7/8" DESCRIPTION1 = "OIL EMBEDDED BRONZE BUSHING 3/4 ID X 7/8 OD X 1 5/8 LONG" End If '============================================================================================================================================= If ID = .752 And OD = 1.002 And LENGTH = .375 Then PART_NUMBER1 = "McMASTER 6391K261" SHAFT_DIA = "3/4" HOUSING_OD = "1" DESCRIPTION1 = "OIL EMBEDDED BRONZE BUSHING 3/4 ID X 1 OD X 3/8 LONG" End If '======================================================================== If ID = .752 And OD = 1.002 And LENGTH = .75 Then PART_NUMBER1 = "McMASTER 6391K263" SHAFT_DIA = "3/4" HOUSING_OD = "1" DESCRIPTION1 = "OIL EMBEDDED BRONZE BUSHING 3/4 ID X 1 OD X 3/4 LONG" End If '============================================================================================================================================== If ID = .752 And OD = 1.002 And LENGTH = 1 Then PART_NUMBER1 = "McMASTER 6391K265" SHAFT_DIA = "3/4" HOUSING_OD = "1" DESCRIPTION1 = "OIL EMBEDDED BRONZE BUSHING 3/4 ID X 1 OD X 1 LONG" End If '========================================================================== If ID = .752 And OD = 1.002 And LENGTH = 1.5 Then PART_NUMBER1 = "McMASTER 6391K268" SHAFT_DIA = "3/4" HOUSING_OD = "1" DESCRIPTION1 = "OIL EMBEDDED BRONZE BUSHING 3/4 ID X 1 OD X 1 1/2 LONG" End If '========================================================================== If ID = .752 And OD = 1.002 And LENGTH = 2 Then PART_NUMBER1 = "McMASTER 6391K269" SHAFT_DIA = "3/4" HOUSING_OD = "1" DESCRIPTION1 = "OIL EMBEDDED BRONZE BUSHING 3/4 ID X 1 OD X 2 LONG" End If '=====================================================================================
0 Likes
Accepted solutions (1)
191 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

Hi @corey_danielson.  This sort of thing can be difficult for someone else to diagnose, but I do have an idea about what the problem may be.  It may be because of the way Inventor / iLogic compares those numerical values for equality.  When you have a value in a rule with a decimal point in it, that is usually understood as a Double type value, which I believe can contain up to 15 digits after the decimal point.  So, 1.00000000001 would not be equal to 1.0000001 in a code based test.  This is especially the case when those values are from measurements or the result of mathematical calculations.  It may only be showing you the 'significant' digits, but not all possible digits.  To get past this, you can use a very handy iLogic tool called 'EqualWithinTolerance', which has two versions.

LmiMath.EqualWithinTolerance Method (Double, Double) 

and

LmiMath.EqualWithinTolerance Method (Double, Double, Double) 

I personally use that second one a lot in several of my iLogic rules, because of how convenient it is, and how it helps avoid those troublesome Double data type value comparisons, because it lets me specify a specific tolerance (the amount the two values can be different, and still be technically equal).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes