Hi,
tmpApp.UnitsOfMeasure.GetStringFromType(Inventor.UnitsTypeEnum.kCentimeterLengthUnits)
returns "zentimeter"
Is there also a function which returns the unit sign "cm" ???
Thanks,
Stephan
Solved! Go to Solution.
Solved by Mike.Wohletz. Go to Solution.
Solved by JohanLarsson. Go to Solution.
Hi,
no suggestions on this case ???
My addin writes a list of dimensions with the unit sign to a csv file and it would really be helpful if I could use a Inventor mechanism instead of translating them manually.
Thanks, Stephan
Depending on what you want to do this might be good enough but it sure is not pretty:
Private Sub test() s = GetUnitString(kCentimeterLengthUnits) End Sub Public Function GetUnitString(oEnum As UnitsTypeEnum) As String oEnum = kCentimeterLengthUnits s = ThisApplication.UnitsOfMeasure.GetLocaleCorrectedExpression("1", oEnum) GetUnitString = Mid(s, 3) End Function
This is how I get it, this uses the document units. The only real difference from what was posted is that trimming off x number of characters will cause issues when document units change and causes decimals to be inserted.
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click MsgBox(GetUomLabel(ThisApplication.ActiveEditDocument.UnitsOfMeasure)) End Sub Public Function GetUomLabel(ByVal DocumentUnits As UnitsOfMeasure) As String Dim StrUnits As String = ThisApplication.UnitsOfMeasure.GetStringFromValue(1, DocumentUnits.LengthUnits) Return StrUnits.Remove(0, StrUnits.LastIndexOf(" ")) End Function