Get part with custom length from content center with VB code

Get part with custom length from content center with VB code

marvin_sahmHP3SG
Participant Participant
473 Views
1 Reply
Message 1 of 2

Get part with custom length from content center with VB code

marvin_sahmHP3SG
Participant
Participant

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:

 

marvin_sahmHP3SG_0-1732024664206.png

In the content center it looks like this:

 

marvin_sahmHP3SG_1-1732024664313.png

 

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

0 Likes
474 Views
1 Reply
Reply (1)
Message 2 of 2

daltonNYAW9
Advocate
Advocate

You will need to add values for the "CustomInput" for the .CreateMember function

 

Example:

https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-place-structural-shapes-channels-h...

 

Try adding something like this:

values = ThisApplication.TransientObjects.CreateNameValueMap
values.Add("B_L", "0.5 in", "Height", "0.5 in")
memberFilename = familie.CreateMember(Row, failureReason, failureMessage,, True, , values)

 

0 Likes