Inventor Vb.Net "AddIn" - Get Frame Generator Cut Length

Inventor Vb.Net "AddIn" - Get Frame Generator Cut Length

isocam
Collaborator Collaborator
195 Views
2 Replies
Message 1 of 3

Inventor Vb.Net "AddIn" - Get Frame Generator Cut Length

isocam
Collaborator
Collaborator

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

0 Likes
196 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor

Can you please upload the complete vb.net project here?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 3

C_Haines_ENG
Collaborator
Collaborator

This works in iLogic. I'm still not sure if you're using VBA or iLogic, but you should be able to convert it.

Sub Main

	Dim oAsm As AssemblyDocument = ThisDoc.Document

	For Each oOcc As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences.AllLeafOccurrences

		If oOcc.ReferencedDocumentDescriptor.ReferencedDocument.DocumentInterests.HasInterest("{AC211AE0-A7A5-4589-916D-81C529DA6D17}") = True _
			And oOcc.Name <> "Frame Reference Model" Then

			Dim Max As Point = oOcc.Definition.RangeBox.MaxPoint
			Dim Min As Point = oOcc.Definition.RangeBox.MinPoint
			Dim oList As New List(Of Double)

			oList.AddRange({Max.X - Min.X, Max.Y - Min.Y, Max.Z - Min.Z })

			MsgBox(oOcc.Name & " = " & oList.Max & "cm")

		End If

	Next

End Sub

 

 

0 Likes