Place one custom member of each content center family into iam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am doing a lot of Content Center customizations to adapt to company standards.
I need one custom member of each family to do customization on the content center family templates. It is a little time-consuming to do this manually on so many parts… Therefore I am looking for an ilogic rule that creates one custom part of each of my custom families in e.g. Fasteners-folder.
One approach could be to run an ilogic rule from an iam that places one custom member of each family into the iam. I have found a starting point on this page… but it is not quite what I am after as you have to type the exact name of the family - I want one of each for every family in the Folder.
Hope someone already has a solution on this or could help out
Sub Main()
PlaceContentCenterPart()
End Sub
Sub PlaceContentCenterPart()
' Set a reference to the active assembly document.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
' Set a reference to the ContentCenter object.
Dim oContentCenter As ContentCenter
oContentCenter = ThisApplication.ContentCenter
' Get the content node (category) "Fasteners:Bolts:Hex Head"
Dim oContentNode As ContentTreeViewNode
oContentNode = oContentCenter.TreeViewTopNode.ChildNodes.Item("Fasteners").ChildNodes.Item("Bolts").ChildNodes.Item("Hex Head")
' Get the "ISO 4015" Family object.
Dim oFamily As ContentFamily
For Each oFamily In oContentNode.Families
If oFamily.DisplayName = "ISO 4015" Then
Exit For
End If
Next
' Create a member based on the first row of the family.
Dim Error1 As MemberManagerErrorsEnum
Dim strContentPartFileName As String
Dim strErrorMessage As String
strContentPartFileName = oFamily.CreateMember(1, Error1, strErrorMessage)
' Dim oMat As Matrix
' oMat = ThisApplication.TransientGeometry.CreateMatrix
' Insert an instance of the content center member in the assembly.
'Call oDoc.ComponentDefinition.Occurrences.Add(strContentPartFileName, oMat)
' Set a reference to the transient geometry object.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
' Create a matrix.
Dim oMatrix As Matrix
oMatrix = oTG.CreateMatrix
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
'place an instance of the component
'in this case at 0,0,0
'positioned at the co-ordinates
oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0))
oOccurrence = oAsmCompDef.Occurrences.Add(strContentPartFileName, oMatrix)
oOccurrence.Grounded = False
End Sub