CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]
CZ | EN | DE
Login or
registration
  Visitors: 19587

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

     docFile.Rebuild
   End If
 Next     
 iLogicVb.UpdateWhenDone = True

end if
Inventor
100% *  CAD 
6.12.2016    11508×  
Prices - CAD eShop:
applies to: Inventor ·

See also:
Tip 13965:Total length of sweeps in Inventor - wires, pipes, trusses, tubes, hoses (iLogic)
Tip 13963:Sum of pipe element lengths in Inventor (iLogic).
Tip 13852:How to bulk-update all model parameters?
Tip 13040:iLogic - display information about complexity of an Inventor part.
Tip 12024:How to create a custom iProperty or Parameter with iLogic?


Back   All CAD Tips



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   



Featuring:
Increase your productivity with our set of BIM add-on functions for Autodesk Revit
CADstudio Revit Tools More info


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