The primary reasons why this is a complex task is that when we access the values of Parameter API objects, that represent values of units other than Text, Boolean, or unitless, is that the values are returned in 'database' units, instead of the units that the parameter is set to. When the units are millimeters, we know that the value we get from the Parameter API object will be in centimeters (not millimeters), so we know that we can simply divide centimeters by 10 to get millimeters. But there are tons of possible units that could be present in any given document, and we do not know how to convert all possible units values.
If I want to manually change how many trailing zeros I see in the parameters dialog for a specific parameter, I can do one of the following.
- If I want more trailing zeros, I re-type the value with the needed number of trailing zeros, except leave the last digit a 1, instead of zero, then after accepting that, I change that last digit from a 1 to a zero. The trailing zeros stay there.
- If I want to completely eliminate any trailing zeros, I can simply re-type the value without any trailing zeros.
- If there is an equation driving the value, then you generally do not have much control over the value, other than placing the equation within one of the few allowed parameter functions.
I had attempted this once before too, but gave up on it, because it just wasn't that important to me at the time.
Dim oDoc As Document = ThisDoc.Document
Dim oParams As Inventor.Parameters = Nothing
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Or
oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
oParams = oDoc.ComponentDefinition.Parameters
ElseIf oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oParams = oDoc.Parameters
Else
Return
End If
If oParams.Count = 0 Then Return
Dim oParam As Inventor.Parameter
For Each oParam In oParams
If oParam.Units = "Text" Or oParam.Units = "Boolean" Or oParam.Units = "ul" Then Continue For
Dim oVal As Double = 0.0
Try
oVal = oParam.Value
oVal = (oVal * 10) / 10
oVal = Ceil(oVal)
oParam.Value = oVal
Catch
End Try
Next
Wesley Crihfield

(Not an Autodesk Employee)