I'm going to add this just in case someone might find it helpful, or in case this can be used to find a solution to getting the size for each component in the assembly. This rule does pretty much the same thing the other does, but as written it writes the extents info all to one custom iProperty named Size (example: Size: 0.3 in. x 0.3 in. x 0.3 in.) It also formats the length of the size string. (example: 0.25 becomes 0.3 in. )
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
'check for custom iprops and add them if not found
Dim propertyName1 As String = "Size"
customPropertySet = ThisDoc.Document.PropertySets.Item _
("Inventor User Defined Properties")
Try
prop = customPropertySet.Item(propertyName1)
Catch
' Assume error means not found
customPropertySet.Add("", propertyName1)
End Try
' Get the active document. This assumes it is a part document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
Dim oBox As Box
oBox = oPartDoc.ComponentDefinition.SurfaceBodies.Item(1).RangeBox
'set IncludeLeadingDigit option
'optional
'use TriState.True to return a number such as 0.123
'use TriState.False to return a number such as .123
'use TriState.UseDefault to use the computer's regional settings
LeadZero = TriState.True
'set NumDigitsAfterDecimal option
'optional
DecNum = 1
'set UseParensForNegativeNumbers
'optional
'use TriState.True to return a negative number as: (49.123)
'use TriState.False to return a negative number as: -49.123
'use TriState.UseDefault to use the computer's regional settings
NegFormat = TriState.False
'set GroupDigits to include group delimiter specified (as specified in the locale settings)
'optional
'use TriState.True to return a number as: 1,234 (where comma is the locale setting)
'use TriState.True to return a number as: 1234
'use TriState.UseDefault to use the computer's regional settings
GroupDigits = TriState.False
Length1 = (oBox.MaxPoint.X - oBox.MinPoint.X) * 0.394 '& " in."
Width1 =(oBox.MaxPoint.Y - oBox.MinPoint.Y) * 0.394 '& " in."
Thickness1 = (oBox.MaxPoint.Z - oBox.MinPoint.Z) * 0.394 '& " in."
Length = FormatNumber(Width1, DecNum, LeadZero, NegFormat, GroupDigits)
Width = FormatNumber(Length1, DecNum, LeadZero, NegFormat, GroupDigits)
Thickness = FormatNumber(Thickness1, DecNum, LeadZero, NegFormat, GroupDigits)
'MessageBox.Show("Extents = " & Thickness & " in. x " & Length & " in. x " & Width & " in. " , "Title")
iProperties.Value("Custom", "Size") = Thickness & " in. x " & Length & " in. x " & Width & " in. "
