iLogic: How to get specific ContentCenter family (by name)

iLogic: How to get specific ContentCenter family (by name)

j.pavlicek
Collaborator Collaborator
1,000 Views
5 Replies
Message 1 of 6

iLogic: How to get specific ContentCenter family (by name)

j.pavlicek
Collaborator
Collaborator

Hello,

I'm trying to get specific Content Center family directly by name.

But it seems there are only three ways how to get specific family.

 

  1. To know a family .InternalName (something like "v3#5c68ec2d-1eba-4318-a3c9-f89754837064#"). It returns family instantly, but I didn't find it in GUI. (And when I want to use this approach, I need to use 3rd way prior, to know InternalName)
  2. To know a family position in Content Center and use cascade of ChildNodes.Item(). ...ContentTreeViewNode.ChildNodes.Item(a).ChildNodes.Item(b)....ChildNodes.Item(z).Families.Item(aa)​

    Sigh! I don't like this long address method.

  3. To iterate trough all Content Center TreeViewNodes and their Families and check Family.DisplayName for match. I'm using this method now, but it takes a LOT of time.

Or is there fourth way how to achieve this?

 

Thanks.



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes
1,001 Views
5 Replies
Replies (5)
Message 2 of 6

j.pavlicek
Collaborator
Collaborator

Error correction:

In first approach is an .ContentIdentifier used instad InternalName.


This is code used for going trough all item in the Content Center and finding families by .DisplayName.

Class ThisRule
	Dim cFamilies As New Collection

	Sub Main
		Dim oConCen As ContentCenter
		oConCen = ThisApplication.ContentCenter
		
		Dim oConNode As ContentTreeViewNode		
		oConNode = oConCen.TreeViewTopNode
		
		' * is wildcard here
		GoThroughNodes(oConNode, , "ISO*")
		LogSelectedFamilies()
	End Sub

	Private Function GoThroughNodes(ByVal oConNode As ContentTreeViewNode, Optional ByVal sNamePattern As String = "*")
		Dim oChildNodes As ContentTreeViewNodesEnumerator
		Dim oConNode2 As ContentTreeViewNode
		
		If oConNode.Families.Count > 0 Then
			GoThroughFamilies(oConNode.Families, sNamePattern)
		End If
		
		oChildNodes = oConNode.ChildNodes
		For Each oConNode2 In oChildNodes
			GoThroughNodes(oConNode2, sNamePattern)
		Next oConNode2
	End Function

	Private Function GoThroughFamilies(ByVal oFamilies As ContentFamiliesEnumerator, Optional ByVal sNamePattern As String = "*")
		Dim oFamily As ContentFamily
		For Each oFamily In oFamilies
			If oFamily.DisplayName Like sNamePattern Then
				cFamilies.Add(oFamily)
			End If
		Next oFamily
	End Function
	
	Private Function LogSelectedFamilies()
		Dim sFamilyIDs As String
		sFamilyIDs = vbNewLine
		
		Dim oFamily As Object
		For Each oFamily In cFamilies
			With oFamily
				sFamilyIDs = sFamilyIDs & .DisplayName & vbNewLine & .ContentIdentifier & vbNewLine
			End With
		Next oFamily
		
		Logger.Debug(sFamilyIDs)
	End Function
End Class


Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes
Message 3 of 6

bradeneuropeArthur
Mentor
Mentor

Hi,

Public Sub CCLoop()

        Dim oContentCenter As ContentCenter
        'Dim oContentCenter As Inventor.ContentCenter ' ThisApplication.ContentCenter
        Set oContentCenter = ThisApplication.ContentCenter
        Dim oToContentNode As ContentTreeViewNode
        
       Set oToContentNode = oContentCenter.TreeViewTopNode
        MsgBox oToContentNode.ChildNodes.Count
        Call loop3(oToContentNode)

End Sub

Public Sub loop3(oContentNodeIn As ContentTreeViewNode)
Dim oContentNode As ContentTreeViewNode
For Each oContentNode In oContentNodeIn.ChildNodes

        'MsgBox oContentNode.Families.Count '.DisplayName
        On Error Resume Next
        Dim f As ContentFamily
        If oContentNode.Families.Count > 0 Then
        
        For Each f In oContentNode.Families
        MsgBox f.DisplayName
        Next
        
        End If
  Call loop3(oContentNode)
        Next

End Sub

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 4 of 6

j.pavlicek
Collaborator
Collaborator

Thanks for reply, but ???

This code does the same what my in the first reply (my is not so simple, because it's rip-off from more complex rule).

 

Problem is speed. One finding takes more than 30 seconds (we have thousands families in our Content Center).



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes
Message 5 of 6

Luke8GL7P
Explorer
Explorer
Hello, I'm also trying to achieve a variable Content Center family name.

Components
.AddContentCenterPart("Fire Pump", "Tube & Pipe:Fittings:Fire Pumps", PumpSeries, {"Designation", GoExcel.CellValue("R14")

Unfortunately, iLogic is only letting me use a "text string" instead of a parameter name...

Any help would be appreciated!!!

 

0 Likes
Message 6 of 6

A.Acheson
Mentor
Mentor

@Luke8GL7P 

I think your post is a little different than the OP. This post relates to the API method to get a family name without knowing the family name in advance. 

 

You might have a formatting issue in your code. If you know the variables you can replace the string values. The below works just plug in your variables. 

Dim sDesignation As String
sDesignation = InputBox("Enter Designation number", "Designation#", "1/2-3/4-3/4")

Dim sFamilyName As String
sFamilyName = InputBox("Enter FamilyName", "sFamilyName", "Threadolet_Reducing_CL3000")


Dim Sockolet_Reducing_CLPos = ThisAssembly.Geometry.Point(-36.710359, -13.762623, 3.279589)
Dim Sockolet_Reducing_CL = Components.AddContentCenterPart("Sockolet Reducing CL3000 6-3:1",
                                                           "Tube & Pipe:Fittings:Branches",
                                                           sFamilyName,
                                                           {"DESIGNATION",sDesignation},
                                                           Sockolet_Reducing_CLPos)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan