Get part with custom length from content center with VB code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I am currently working on a VB script to get custom parts from the content center. Just for testing I tried to get some regular parts which worked great. But now I want to get a part where the user has to type in the length when placing it manually.
For now I am just using a block, the preset lenght is 50mm. When selecting the part it looks like this:
In the content center it looks like this:
I have created this code which gets the part into the assembly with the preset 50mm, but now I want the code to set the lenght to lets say 80mm. Ive tried some things but nothing worked and I am getting a little frustrated. Is there a solution for this or do I have to get each length as row in the content family? That would be not optimal, because later on there will be length, width and heigth that have to be selected. Creating a row for each variant would result in a couple million entries of which most will never be used.
Public Sub VonCC_OnExecute(Context As NameValueMap) Handles VonCC.OnExecute
Dim ZusDok As AssemblyDocument
ZusDok = g_inventorApplication.ActiveDocument
Dim oContentCenter As ContentCenter = g_inventorApplication.ContentCenter
Dim Rechteck As ContentTreeViewNode
Rechteck = g_inventorApplication.ContentCenter.TreeViewTopNode.ChildNodes.Item("Profile").ChildNodes.Item("Item Profile").ChildNodes.Item("Profil 8")
Dim familie As ContentFamily
Dim checkfamilie As ContentFamily
For Each checkfamilie In Rechteck.Families
If checkfamilie.DisplayName = "Rechteck_variabel2" Then
familie = checkfamilie
Exit For
End If
Next
If Not familie Is Nothing Then
Dim row As ContentTableRow
row = familie.TableRows.Item(1)
Dim failureReason As MemberManagerErrorsEnum
Dim failureMessage As String = "Fehler"
Dim memberFilename As String
memberFilename = familie.CreateMember(row, failureReason, failureMessage)
Dim transMatrix As Matrix
transMatrix = g_inventorApplication.TransientGeometry.CreateMatrix
transMatrix.Cell(2, 4) = 0
Dim Occ As ComponentOccurrence
Occ = ZusDok.ComponentDefinition.Occurrences.Add(memberFilename, transMatrix)
End If
End Sub
I am using Inventor 2023 and Visual Studio 2019.
I would really appreciate it to get a hint how it could be done.
Kind regards
Marvin