Autodesk Inventor
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
ILogic rule to change all units
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi All
I am after a rule to change the unit type of all .ipts from cm to mm.
This has to go down to all levels in hierarchy but only change .ipt files
any code would be appreciated
Dave
Solved! Go to Solution.
Re: ILogic rule to change all units
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi dclunie,
I think this will work for you (if you modify it a bit):
'get input from user
oUnit = InputRadioBox("Select a units of measure type", "Metric", "Imperial", False, "ilogic")
If oUnit = True then
'set to millimeter
oUOM_1 = UnitsTypeEnum.kMillimeterLengthUnits
'set to kilogram
oUOM_2 = UnitsTypeEnum.kKilogramMassUnits
Else
'set to inch
oUOM_1 = UnitsTypeEnum.kInchLengthUnits
'set to pounds mass
oUOM_2 = UnitsTypeEnum.kLbMassMassUnits
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
'set mass units
docFile.unitsofmeasure.MassUnits = oUOM_2
'rebuild to update the display
docFile.Rebuild
End If
Next
iLogicVb.UpdateWhenDone = True
This is a variation of this rule:
http://inventortrenches.blogspot.com/2012/05/ilogi
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Re: ILogic rule to change all units
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Here's a version specifically, directed toward changing from mm to cm:
'get input from user
oUnit = InputRadioBox("Select a units of measure type", "millimeter", "centimeter", True, "ilogic")
If oUnit = True then
'set to millimeter
oUOM_1 = UnitsTypeEnum.kMillimeterLengthUnits
Else
'set to centimeter
oUOM_1 = UnitsTypeEnum.kCentimeterLengthUnits
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 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Re: ILogic rule to change all units
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

