Inventor Vb.Net "AddIn" - Get Frame Generator Cut Length
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anybody help?
I am trying, using a Vb.Net "AddIn", to get the lengths of each separate member in a frame, generated using the frame generator tool in Inventor.
Below is my code so far....
Sub GetCutLengths(oDoc)
Dim oAsm As AssemblyDocument
Dim oOcc As ComponentOccurrence
Dim oUM As UnitsOfMeasure
oUM = oDoc.UnitsOfMeasure
For Each oOcc In oAsm.ComponentDefinition.Occurrences.AllLeafOccurrences
oDoc = oOcc.Definition.Document
Dim maxz As Double
Dim minz As Double
Dim height As Double
maxz = oOcc.Definition.rangeBox.MaxPoint.Z
minz = oOcc.Definition.rangeBox.MinPoint.Z
height = maxz - minz
On Error Resume Next
If height <> 0 Then
oDoc.ComponentDefinition.Parameters.UserParameters.Item("G_L").Value = height
SectionType = oDoc.PropertySets.Item("Content Library Component Properties").Item("Family").Value
Select Case SectionType
Case "DIN 59410 (Rectangular)"
SectionType = "RHS"
Case "DIN 59410 (Square)"
SectionType = "SHS"
End Select
Size = oDoc.PropertySets.Item("Design Tracking Properties").Item("Size Designation").Value
Size = Replace(Size, "x", " x ")
Length = Trim(Str(Val(oUM.GetStringFromValue(height, oUM.LengthUnits))))
PartDescription = SectionType + ": " + Size + " x " + Length + " LONG"
Msgbox(PartDescription)
End If
Next
End Sub
I am having issues with the first three lines of code (Highlighted in red).
Does anybody have any idea what is wrong?
Many thanks in advance!
Darren