Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unit of Dimensions

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
wannensn
468 Views, 4 Replies

Unit of Dimensions

Hi,

 

tmpApp.UnitsOfMeasure.GetStringFromType(Inventor.UnitsTypeEnum.kCentimeterLengthUnits)

 returns "zentimeter"

 

Is there also a function which returns the unit sign "cm" ???

 

Thanks,

Stephan

4 REPLIES 4
Message 2 of 5
wannensn
in reply to: wannensn

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

Message 3 of 5
JohanLarsson
in reply to: wannensn

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

 

-------------------------------------------------------------------------
Inventor Professional 2012 SP1 (25 seats with subscription)
Windows 7 64 bit
Lenovo D20, 12 GB RAM, Intel Xeon X5687 3.6 GHz, SSD
Quadro 4000, driver 8.17.12.9573, dual monitors
SpacePilot, driver version 6.15.3 Firmware 3.12
Message 4 of 5
Mike.Wohletz
in reply to: wannensn

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

 

Message 5 of 5
wannensn
in reply to: Mike.Wohletz

Both solution are working - thanks.

 

--Stephan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report