changing model units API

changing model units API

NemKumar
Enthusiast Enthusiast
1,876 Views
1 Reply
Message 1 of 2

changing model units API

NemKumar
Enthusiast
Enthusiast

Hi All, 

 

I can get the current units of the model (lets say its mm), but I wanna change the units to meter and save the file.

I could not find any API to perform this task. Though I know the document settings UI in Inventor but I need API to do that.

 

Thanks in Advance,

Tikeshwar

 

 

0 Likes
Accepted solutions (1)
1,877 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

I have a code which allows the change from mm to inches which could be adapted to suit your needs.

Hope this helps.

 

'get input from user
oUnit = InputRadioBox("Select a units of measure type", "millimeter", "inch", True, "ilogic")
If oUnit = True Then
'set to millimeter
oUOM_1 = UnitsTypeEnum.kMillimeterLengthUnits
Else
'set to inch
oUOM_1 = UnitsTypeEnum.kInchLengthUnits
End If
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments
'look at only part files
If docFile.DocumentType = kPartDocumentObject Then
'format file name
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
'set length units
docFile.unitsofmeasure.LengthUnits = oUOM_1
'rebuild to update the display
docFile.Rebuild
End If
Next
iLogicVb.UpdateWhenDone = True

0 Likes