CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
Cesky English Deutsch
 Visitors: 2115 

CAD tip CAD tip # 11211:

Question CAD 
 %  platform  category 
Q - question

Mass change of units in the whole Inventor assembly.

A - answer With the following iLogic macro (rule) you can easily change length and mass units in all parts of the current Inventor assembly - e.g. to mm and grams:

sureq = MessageBox.Show("Do you really want to change units in the whole assembly?", "iLogic", MessageBoxButtons.YesNo)
if sureq = vbYes then

' preset units
 oUOM1 = UnitsTypeEnum.kMillimeterLengthUnits ' or UnitsTypeEnum.kCentimeterLengthUnits
 oUOM2 = UnitsTypeEnum.kGramMassUnits ' or UnitsTypeEnum.kKilogramMassUnits
 oPrecision = 3

 dim openDoc as document
 openDoc = ThisDoc.Document
 openDoc.unitsofmeasure.LengthUnits = oUOM1 
 openDoc.unitsofmeasure.MassUnits = oUOM2
 openDoc.unitsofmeasure.LengthDisplayPrecision = oPrecision

 dim docFile as document 
 For Each docFile In openDoc.AllReferencedDocuments 
  ' parts only
   If docFile.DocumentType = kPartDocumentObject Then 
     dim FNamePos as long
     FNamePos = InStrRev(docFile.FullFileName, "\", -1)                         
     dim docFName as string  
     docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)       

     docFile.unitsofmeasure.LengthUnits = oUOM1
     docFile.unitsofmeasure.MassUnits = oUOM2
     docFile.unitsofmeasure.LengthDisplayPrecision = oPrecision

   End If
 iLogicVb.UpdateWhenDone = True

end if
100% *  CAD 
6.12.2016    4172×  
applies to: Inventor ·

See also:
Tip 12024:How to create a custom iProperty or Parameter with iLogic?
Tip 9952:iLogic rule - check whether iProperties are overridden.
Tip 8986:Material density as a custom iProperty in Inventor.

Back   All CAD Tips All CAD tips&tricks

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   

Extend your AutoCAD LT productivity with our popular add-on
CADstudio LT Extension More info

Please use these tips at your own risk.
CAD Studio is not responsible for possible problems that may occur as a result of using any of these tips.