• Blog posts

    Bio

    by Clint Brown

    Today’s blog is an improvement on some work I did last year (see part1 of this blog)

    In some instances it is necessary to view the iProperties of a model in both Metric and Imperial format.

    To achieve this, I have written a bit of iLogic code to extract the information that we need. The Code creates a few custom iProperties and does some unit conversions based on Imperial/Metric conversions. We are then presented with a message box which tells us what the current document units are, and then displays Area, Mass and Volume in both imperial and metric measurements.

    To add this to your model (part or assembly), simply create a new rule in your part or assembly, and paste in this code into it.

     

    '----------------START OF iLOGIC CODE-----------------------------------
    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
    
    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 ("This Documents units are  " & _
    iProperties.Value("Custom", "UNITMASTER")& vbLf & vbLf & _
    "Area    =   " & iProperties.Value("Custom", "Area") & " mm^2" & _
    vbLf & "Mass    =   " & iProperties.Value("Custom", "Mass") & " kg" & vbLf & _
    "Volume    =   " & iProperties.Value("Custom", "Volume") & vbLf & vbLf & _ 
    "Area    =   " & iProperties.Value("Custom", "AreaIMP") & " in^2" & _
    vbLf & "Mass    =   " & iProperties.Value("Custom", "MassIMP") & " lbs" & vbLf & _
    "Volume    =   " & iProperties.Value("Custom", "VolumeIMP") & _
    " in^3", "www.CadlineCommunity.co.uk")

    '--------------------END OF iLOGIC CODE-----------------------------------

Comments

0 comments

Please sign in to leave a comment.