- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am building a configurator for my company that will rely heavily on Content Center parts. I have made several iterations of my code but keep stumbling on what seems to be the same underlying problem - Querying the Content Center before it is fully "initialized" crashes Inventor.
For example, if I have been running Inventor for a while and used CC at some point, then the code runs fine (usually) but if I start a fresh session of Inventor and run my code before doing any UI operations it tends to crash (freezing/hanging only happens when debugging thru Visual Studio, otherwise it just crashes Inventor outright).
Debugging my DLL, I could determine that Inventor froze on this line:
Dim treeNode As ContentTreeViewNode = _contentCenter.TreeViewTopNode
I thought I had then discovered the solution by "initializing" CC with this code:
Dim command As ControlDefinition = _invApp.CommandManager.ControlDefinitions.Item("CCV2PlaceButton")
command.Execute()
Dim treeNode As ContentTreeViewNode = _contentCenter.TreeViewTopNode
_invApp.CommandManager.StopActiveCommand()
As clicking the "Place from Content Center"-button before running my code made it work without freezing...But that only worked until here:
Dim childNodes As ContentTreeViewNodesEnumerator = treeNode.ChildNodes
'Dim child As ContentTreeViewNode = treeNode.ChildNodes
I then tried generating a member thru the UI before running the code which then made the "ChildNodes"-line pass but only until a different family was requested and the code froze again (edit: actually it was the same family but the next "section" of the path, i.e. "Tube & Pipe" & "|" & "Fittings"...and here it hangs).
Is there some other way to load CC to avoid these problems or is there something else I can do? My code gets the full CC path from a configuration file so if there's a way to access the family directly I guess I wouldn't need to loop thru CC to find the path/family object.
Here's the function that gets the CC families and is currently not working:
Public Function GetFamilyData(ccPath As String, familyName As String) As ContentCenterFamilyLookup
Dim key As String = ccPath & "|" & familyName
Dim familyData As ContentCenterFamilyLookup = Nothing
If _familyCache.TryGetValue(key, familyData) Then Return familyData
Dim nodeNames() As String = ccPath.Split(":"c)
Dim treeNode As ContentTreeViewNode = _contentCenter.TreeViewTopNode
For Each nodeName As String In nodeNames
Dim foundNode As ContentTreeViewNode = Nothing
For Each child As ContentTreeViewNode In treeNode.ChildNodes
If String.Equals(child.DisplayName, nodeName, StringComparison.OrdinalIgnoreCase) Then
foundNode = child
Exit For
End If
Next
If foundNode Is Nothing Then Throw New Exception("Content Center node not found: " & nodeName)
treeNode = foundNode
Next
For Each family As ContentFamily In treeNode.Families
If String.Equals(family.DisplayName, familyName, StringComparison.OrdinalIgnoreCase) Then
familyData = IndexFamilyData(family, ccPath)
_familyCache(key) = familyData
Return familyData
End If
Next
Throw New Exception("Content Center family not found: " & ccPath & " | " & familyName)
End Function
We use Inventor 2025/Vault Pro 2025, a single project file setup and a Vaulted Content Center. My DLL is currently setup to run on net8.0
I should also mention that running CC locally seems much more stable...
Best,
Fredrik
Solved! Go to Solution.