Display Inventor iProperties as Dual Units with iLogic - Part1

Zen Admin
Zen Admin
  • Updated

by Clint Brown

I've been working on some iLogic code for creating dual units in Inventor, the idea is that we can look at a file's iProperties in both Metric and Imperial format.

The Code creates a few custom iProperties and does some unit conversions based on Imperial/Metric conversions, and then shows 3 Message boxes, the first tells us which Units are active in the file, and the next 2 show Metric and Imperial units respectively.

To Get this to work, simply create a new rule in your Part or Assembly, and paste in this code into it.

Please double check that the calculations are correct before using this in production. Let me know if there are any issues, by commenting below.

CadlineDoc = ThisDoc.Document
iProperties.Value("Custom", "UNITlength") = CadlineDoc.unitsofmeasure.LengthUnits
iProperties.Value("Custom", "UNITmass") = CadlineDoc.unitsofmeasure.MassUnits
If iProperties.Value("Custom", "UNITlength") = 11269 And
iProperties.Value("Custom", "UNITmass")= 11283 Then
iProperties.Value("Custom", "UNITMASTER") = "Metric"
Else If iProperties.Value("Custom", "UNITlength") = 11272 And
iProperties.Value("Custom", "UNITmass") = 11286 Then
iProperties.Value("Custom", "UNITMASTER") = "Imperial"
End If

MessageBox.Show("This Documents units are  " & _
iProperties.Value("Custom", "UNITMASTER"), "www.CadlineCommunity.co.uk")

If iProperties.Value("Custom", "UNITMASTER") = "Metric" Then
'Write Metric Props to Custom iProps
iProperties.Value("Custom", "Area") = Round(iProperties.Area, 2)
iProperties.Value("Custom", "Mass") = Round(iProperties.Mass, 2)
iProperties.Value("Custom", "Volume") = Round(iProperties.Volume, 2)
'Write Imperial Props to Custom iProps
iProperties.Value("Custom", "AreaIMP") = Round((iProperties.Area*0.001550003100006), 2)
iProperties.Value("Custom", "MassIMP") = Round((iProperties.Value("Custom", "Mass")*2.20462), 2)
iProperties.Value("Custom", "VolumeIMP") = Round((iProperties.Volume*0.0000610237), 2)
End If

If iProperties.Value("Custom", "UNITMASTER") = "Imperial" Then
'Write Metric Props to Custom iProps
iProperties.Value("Custom", "Area") = Round(iProperties.Area/0.001550003100006, 2)
iProperties.Value("Custom", "Mass") = Round((iProperties.Mass/2.20462), 2)
iProperties.Value("Custom", "Volume") = Round(iProperties.Volume/0.0000610237, 2)
'Write Imperial Props to Custom iProps
iProperties.Value("Custom", "AreaIMP") = Round((iProperties.Area), 2)
iProperties.Value("Custom", "MassIMP") = Round((iProperties.Value("Custom", "Mass")), 2)
iProperties.Value("Custom", "VolumeIMP") = Round((iProperties.Volume), 2)
End If

MessageBox.Show ("METRIC UNITS:"& vbLf & vbLf & _
"Area Of Part   =   " & iProperties.Value("Custom", "Area") & " mm^2" & _
vbLf & "Mass of Part   =   " & iProperties.Value("Custom", "Mass") & " kg" & vbLf & _
"Volume of Part   =   " & iProperties.Value("Custom", "Volume") & _
" mm^3", "www.CadlineCommunity.co.uk")
MessageBox.Show ("IMPERIAL UNITS:"& vbLf & vbLf & _
"Area of Part   =   " & iProperties.Value("Custom", "AreaIMP") & " in^2" & _
vbLf & "Mass of Part   =   " & iProperties.Value("Custom", "MassIMP") & " lbs" & vbLf & _
"Volume of Part   =   " & iProperties.Value("Custom", "VolumeIMP") & _
" in^3", "www.CadlineCommunity.co.uk")

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.