Ok, so I've fixed the issue with 3 mm thickness, the forgotten "oSMDef.Unfold()" and I've added an example for the material (for thickness 10 mm):
Here's what was the issue: modthemachine/floating-point-numbers
Dim oPart As PartDocument = ThisApplication.ActiveDocument
Dim oSMDef As SheetMetalComponentDefinition = oPart.ComponentDefinition
If Not oSMDef.HasFlatPattern Then oSMDef.Unfold()
iProperties.Value("Custom", "Length")=Round(SheetMetal.FlatExtentsLength, 1)
iProperties.Value("Custom", "Width")=Round(SheetMetal.FlatExtentsWidth, 1)
iProperties.Value("Custom", "Description") = "=Sheet t.<Tloušťka> <Length>x<Width> "
iProperties.Value("Project", "Description") = "=Sheet t.<Tloušťka> <Length>x<Width> "
Parameter.Param("Tloušťka").ExposedAsProperty = True
Dim smFormat As CustomPropertyFormat = Parameter.Param("Tloušťka").CustomPropertyFormat
smFormat.ShowTrailingZeros = False
smFormat.ShowUnitsString = False
'Read the Material
Dim oMat As String = iProperties.Material
'Get the thickness parameter as a value
Dim oThick As Single = Round(Parameter("Tloušťka").Value, 3) 'Round to 3 decimal numbers
'Check the value and set the iProperty's value
Select Case oThick
Case 2: iProperties.Value("Project", "Stock Number") = "131000006"
Case 2.5: iProperties.Value("Project", "Stock Number") = "131000008"
Case 3: iProperties.Value("Project", "Stock Number") = "131000009"
Case 4: iProperties.Value("Project", "Stock Number") = "131000011"
Case 5: iProperties.Value("Project", "Stock Number") = "131000013"
Case 6: iProperties.Value("Project", "Stock Number") = "131000016"
Case 7: iProperties.Value("Project", "Stock Number") = "131000018"
Case 8: iProperties.Value("Project", "Stock Number") = "131000019"
Case 9: iProperties.Value("Project", "Stock Number") = "131000020"
Case 10:
If oMat = "S 235 JR" Then
iProperties.Value("Project", "Stock Number") = "5555"
ElseIf oMat = "DC01" Then
iProperties.Value("Project", "Stock Number") = "9999"
End If
Case 12: iProperties.Value("Project", "Stock Number") = "131000022"
Case 14: iProperties.Value("Project", "Stock Number") = "131000023"
Case 15: iProperties.Value("Project", "Stock Number") = "131000024"
Case 20: iProperties.Value("Project", "Stock Number") = "131000025"
End Select
If you have more than 2 material options (or you simply want to use it instead), you can use "Select Case" again:
Select Case oThick
'...
Case 10:
Select Case oMat
Case "S 235 JR": iProperties.Value("Project", "Stock Number") = "5555"
Case "DC01": iProperties.Value("Project", "Stock Number") = "9999"
End Select
Case 12: iProperties.Value("Project", "Stock Number") = "131000022"
'...
End Select
Note: "Select Case" is a faster option for numeric selections, but it doesn't matter for text comparing (the speed is the same).
You cloud also shorten it to single line selects (to make the code look tidy and easy to read):
Dim oStock As String = vbNullString
Select Case oThick
'...
Case 10: If oMat = "S 235 JR" Then oStock = "5555" Else oStock = "9999"
Case 12: oStock = "131000022"
'...
End Select
If oStock <> vbNullString Then iProperties.Value("Project", "Stock Number") = oStock
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