Inventor General Discussion

Inventor General Discussion

Reply
Valued Contributor
dclunie
Posts: 70
Registered: ‎03-26-2008
Message 1 of 4 (710 Views)
Accepted Solution

ILogic rule to change all units

710 Views, 3 Replies
11-25-2012 09:07 PM

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

 

Convert to mm.JPG

*Expert Elite*
Curtis_Waguespack
Posts: 2,878
Registered: ‎03-08-2006
Message 2 of 4 (687 Views)

Re: ILogic rule to change all units

11-26-2012 10:11 AM in reply to: dclunie

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/ilogic-rule-to-change-units-of-measure.html

 

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





*Expert Elite*
Curtis_Waguespack
Posts: 2,878
Registered: ‎03-08-2006
Message 3 of 4 (679 Views)

Re: ILogic rule to change all units

11-26-2012 10:22 AM in reply to: Curtis_Waguespack

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



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





*Expert Elite*
scottmoyse
Posts: 1,634
Registered: ‎06-10-2009
Message 4 of 4 (564 Views)

Re: ILogic rule to change all units

03-18-2013 12:48 PM in reply to: Curtis_Waguespack

Curtis,

 

Since the OP didn't say thank you I will. This just saved one of my staff a tonne of time. Thank you very much!

 

Cheers


Scott.

Cheers
Scott Moyse

Please use Mark Solutions!.Accept as Solution &Give Kudos!Kudos to further enhance the value of these forums. Cheers!


   

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.