Hello. Newbie here. Using Inventor Pro 2019 with Visual Studio 2017. My script reads the content center child node levels and puts them in a LONG string; which is printed to a message box. Unfortunately because of the length of the string and no scroll bars, I can't see the bottom of the list. So I would like to pass the string to a secondary form that has a text box with scroll bars. I do not have enough experience with .net to get code snippets from the internet to work. Do you know how to do this?
Module code:
Imports System Imports System.Type Imports System.Activator Imports System.Runtime.InteropServices Imports Inventor Module Module1 Sub Main() Dim invApp As Inventor.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") Dim invDoc As Inventor.Document = invApp.ActiveDocument 'this gets all of the child nodes in the content center and puts them in a string list For Each Node1 As ContentTreeViewNode In TopNode.ChildNodes StrCCList &= Node1.DisplayName & vbNewLine For Each Node2 As ContentTreeViewNode In TopNode.ChildNodes.Item(Node1.DisplayName).ChildNodes StrCCList &= " " & " " & Node2.DisplayName & vbNewLine For Each Node3 As ContentTreeViewNode In TopNode.ChildNodes.Item(Node1.DisplayName).ChildNodes.Item(Node2.DisplayName).ChildNodes StrCCList &= " " & " " & " " & " " & Node3.DisplayName & vbNewLine For Each Node4 As ContentTreeViewNode In TopNode.ChildNodes.Item(Node1.DisplayName).ChildNodes.Item(Node2.DisplayName).ChildNodes.Item(Node3.DisplayName).ChildNodes StrCCList &= " " & " " & " " & " " & " " & " " & Node4.DisplayName & vbNewLine Next Next Next Next 'reads the string list of the content center nodes 'MsgBox(StrCCList) Dim FamResults As New FamResults(StrCCList) 'FamResults.Activate() 'FamResults.Show() 'FamResults.TextBox1.Text = StrCCList End Sub End Module
Secondary form code:
Public Class FamResults Public Sub New(ByVal PropSetString) ' This call is required by the designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged 'Dim TextOutput As String = sender 'Dim TextOutput As String = "Family Results popup dialog" 'MsgBox(TextOutput) 'TextBox1.Text = TextOutput End Sub Private Sub ExitButton_Click(sender As Object, e As EventArgs) Handles ExitButton.Click Me.Close() End Sub End Class
Solved! Go to Solution.
Solved by snappyjazz. Go to Solution.
I figured it out. In the section of code below is where I went wrong.
Dim FamResults As New FamResults(StrCCList)FamResults.Activate()FamResults.Show() FamResults.TextBox1.Text = StrCCList
The result is that the script gets all of the levels of the content center and puts them in a string (a long string). This string is then put in the text box of a form with scroll bars, so you can scroll down and see the whole hierarchy.
Final Code:
Imports System Imports System.Type Imports System.Activator Imports System.Runtime.InteropServices Imports Inventor Module Module1 Sub Main() Dim invApp As Inventor.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") Dim invDoc As Inventor.Document = invApp.ActiveDocument Dim ConCen As ContentCenter = invApp.ContentCenter Dim TopNode As ContentTreeViewNode = invApp.ContentCenter.TreeViewTopNode Dim StrCCList As String = " " & " " & " " & " " & " " & "Content Center Breakdown" & vbNewLine 'this gets all of the child nodes in the content center and puts them in a string list For Each Node1 As ContentTreeViewNode In TopNode.ChildNodes StrCCList &= Node1.DisplayName & vbNewLine For Each Node2 As ContentTreeViewNode In TopNode.ChildNodes.Item(Node1.DisplayName).ChildNodes StrCCList &= " " & " " & Node2.DisplayName & vbNewLine For Each Node3 As ContentTreeViewNode In TopNode.ChildNodes.Item(Node1.DisplayName).ChildNodes.Item(Node2.DisplayName).ChildNodes StrCCList &= " " & " " & " " & " " & Node3.DisplayName & vbNewLine For Each Node4 As ContentTreeViewNode In TopNode.ChildNodes.Item(Node1.DisplayName).ChildNodes.Item(Node2.DisplayName).ChildNodes.Item(Node3.DisplayName).ChildNodes StrCCList &= " " & " " & " " & " " & " " & " " & Node4.DisplayName & vbNewLine Next Next Next Next 'reads the string list of the content center nodes Dim FamRes As New FamResults(StrCCList) FamRes.TextBox1.Text = StrCCList FamRes.ShowDialog() End Sub End Module
Public Class FamResults Public Sub New(ByVal PropSetString) ' This call is required by the designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub ExitButton_Click(sender As Object, e As EventArgs) Handles ExitButton.Click Me.Close() End Sub End Class
PS. You have to have an .ipt open for this to get the Content Center. I don't have the skill yet to check if an .ipt is open.
Can't find what you're looking for? Ask the community or share your knowledge.