Ilogic Not Matching If Test

Ilogic Not Matching If Test

rttechno
Advocate Advocate
399 Views
3 Replies
Message 1 of 4

Ilogic Not Matching If Test

rttechno
Advocate
Advocate

Hi,

 

I'm working on a simple bit of code that will allow me to change to a predetermined sheet metal style based on the existing thickness in a file.  My customer changed shops and I need to switch to the bend rads they have available.  I am just running the code in each file as I open them.  It works for every thickness except 12 GA. (.1046).  The parameter in the document is .1046 but it doesn't pass the IF test and execute the code within.  I'm sure it's something stupid but I can't find it...  Any ideas?

 

MessageBox.Show(Parameter("Thickness"), "Param Value")

If Parameter("Thickness") = .125
	SheetMetal.SetActiveStyle(".125 .125 Rad")
	MessageBox.Show(SheetMetal.GetActiveStyle, "Title")
Else If Parameter("Thickness") = .5
	SheetMetal.SetActiveStyle("1/2" & """" & " .2366 Rad")
	MessageBox.Show(SheetMetal.GetActiveStyle, "Title")
Else If Parameter("Thickness") = .25
	SheetMetal.SetActiveStyle("1/4" & """" & " .1719 Rad")
	MessageBox.Show(SheetMetal.GetActiveStyle, "Title")
Else If Parameter("Thickness") = .1046
	SheetMetal.SetActiveStyle("12 Ga .0781 Rad")
	MessageBox.Show(SheetMetal.GetActiveStyle, "Title")
Else If Parameter("Thickness") = .1345
	SheetMetal.SetActiveStyle("10 Ga .125 Rad")
	MessageBox.Show(SheetMetal.GetActiveStyle, "Title")
Else If Parameter("Thickness") = .0747
	SheetMetal.SetActiveStyle("14 Ga .0781 Rad")
	MessageBox.Show(SheetMetal.GetActiveStyle, "Title")
Else If Parameter("Thickness") = .1875
	SheetMetal.SetActiveStyle("3/16" & """" & " .125 Rad")
	MessageBox.Show(SheetMetal.GetActiveStyle, "Title")
Else If Parameter("Thickness") = .375
	SheetMetal.SetActiveStyle("3/8" & """" & " .1719 Rad")
	MessageBox.Show(SheetMetal.GetActiveStyle, "Title")
Else If Parameter("Thickness") = .3125
	SheetMetal.SetActiveStyle("5/16" & """" & " .0781 Rad")
	MessageBox.Show(SheetMetal.GetActiveStyle, "Title")
End If

 

RT Technologies

Autodesk Inventor 2017

Windows 10

 

 

0 Likes
Accepted solutions (1)
400 Views
3 Replies
Replies (3)
Message 2 of 4

Owner2229
Advisor
Advisor
Accepted solution

Hey, my guess would be floating point numbers:

http://modthemachine.typepad.com/my_weblog/2013/08/comparing-floating-point-numbers.html

 

Try it like this:

 

 

MessageBox.Show(Parameter("Thickness"), "Param Value")

Dim oVal As Double = Parameter("Thickness")
Dim oStyle As String = vbNullString
Select Case Math.Round(oVal, 4)
Case .125:		oStyle = ".125 .125 Rad"
Case .5:		oStyle = "1/2" & """" & " .2366 Rad"
Case .25:		oStyle = "1/4" & """" & " .1719 Rad"
Case .1046:		oStyle = "12 Ga .0781 Rad"
Case .1345:		oStyle = "10 Ga .125 Rad"
Case .0747:		oStyle = "14 Ga .0781 Rad"
Case .1875:		oStyle = "3/16" & """" & " .125 Rad"
Case .375:		oStyle = "3/8" & """" & " .1719 Rad"
Case .3125:		oStyle = "5/16" & """" & " .0781 Rad"
Case Else:	Exit Sub
End Select

SheetMetal.SetActiveStyle(oStyle)
MessageBox.Show(SheetMetal.GetActiveStyle, "Title")

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 4

rttechno
Advocate
Advocate

Hi Mike,

 

Thanks for the quick response.  I'll give it a shot!

 

Randy

0 Likes
Message 4 of 4

rttechno
Advocate
Advocate

Worked perfect.  Thanks so much!  What a weird issue...

0 Likes