Mass units in iLogic

My variation of way to get a mass to a drawing. This macro for iLogic solve the problem of different units "kg" and "g". May by next time I add libra unit. I used this because this way solve mass only before save model, not with every change.

Select Case ThisDoc.Document.UnitsOfMeasure.Massunits
    Case 11283  'kilogram
        If iProperties.Mass > 0.1 Then 
            iProperties.Value("Custom", "Hmotnost") = Round(iProperties.Mass,2) & " kg"
        Else 
            iProperties.Value("Custom", "Hmotnost") = Round(iProperties.Mass * 1000) & " g"
        End If
    Case 11284  'gram
        If iProperties.Mass > 100 Then 
            iProperties.Value("Custom", "Hmotnost") = Round(iProperties.Mass / 1000,2) & " kg"
        Else 
            iProperties.Value("Custom", "Hmotnost") = Round(iProperties.Mass) & " g"
        End If
End Select

No comments: