Friday, December 22, 2017
ilogic Rule To Change Units Of Measure
ilogic Rule To Change Units Of Measure

Issue:
Youve created some of your parts in inches and others in millimeters, but now youd 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:
Heres 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:
http://inventortrenches.blogspot.com/2012/01/creating-basic-ilogic-rule-with-event.html
http://autodeskmfg.typepad.com/blog/2012/01/working-with-external-ilogic-rules.html
------- 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
link download