Issue:
You've created some of your parts in inches and others in millimeters, but now you'd like to convert them all to be the same. Is there a quick way to do this without having to open each file go to the Tools tab > Document Settings button > Unitstab?
Solution:
Here's an ilogic rule that can be run in an assembly or a part file that will set the units of measure. In this rule the length and mass units are being set. Set this up as an external iLogic rule to have it available for use in all of your model files.
You can use these links to learn more about creating iLogic rules:
'------- start of ilogic ------
question = MessageBox.Show("Are you sure you want to change the units of measure?", _
"iLogic",MessageBoxButtons.YesNo)
if question = vbno then
Return
Else
'get input from user
oUnit = InputRadioBox("Select a units of measure type", "Metric", "Imperial", True, "ilogic")
'create precision value list
oPrecisionArray = new string(){0, 1, 2, 3, 4, 5}
'get input from user
oPrecision = InputListBox("Select the number of decimal places to use for the units of length display.", _
oPrecisionArray, 3, "iLogic", "Decimal Places ")
'example UnitsTypeEnum Enumerators
'kCentimeterLengthUnits = 11268
'kMillimeterLengthUnits = 11269
'kInchLengthUnits = 11272
'kKilogramMassUnits = 11283
'kGramMassUnits = 11284
'kLbMassMassUnits = 11286
If oUnit = True then
'set to millimeter
oUOM_1 = 11269
'set to kilogram
oUOM_2 = 11283
Else
'set to inch
oUOM_1 = 11272
'set to pounds mass
oUOM_2 = 11286
End if
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'set length units for the top level assembly
openDoc.unitsofmeasure.LengthUnits = oUOM_1
'set mass units for the top level assembly
openDoc.unitsofmeasure.MassUnits = oUOM_2
'set precision
openDoc.unitsofmeasure.LengthDisplayPrecision = oPrecision
'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments
'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
'set mass units
docFile.unitsofmeasure.MassUnits = oUOM_2
'set precision
docFile.unitsofmeasure.LengthDisplayPrecision = oPrecision
'rebuild to update the display
docFile.Rebuild
Next
End if
'update all
iLogicVb.UpdateWhenDone = True
'------- end of ilogic ------