Content Center Add Columns

Content Center Add Columns

KWarrenCA
Advocate Advocate
458 Views
1 Reply
Message 1 of 2

Content Center Add Columns

KWarrenCA
Advocate
Advocate

I'm creating a VBA code that will add a new column to every family table in a folder in the content center editor. I have the code working correctly but the only issue I have is I would like to map the column to a custom iproperty but running into how to do that. So far I haven't found here I can pull that information from.

KWarrenCA_0-1742908749522.png

 

Sub ModifyFamilyTable()

    Dim oContentCenter As ContentCenter
    Set oContentCenter = ThisApplication.ContentCenter
    
    Dim hexHeadNode As ContentTreeViewNode
    Set hexHeadNode = ThisApplication.ContentCenter.TreeViewTopNode.ChildNodes.Item("Tube & Pipe").ChildNodes.Item("Fittings").ChildNodes.Item("Adapters")
    
    Dim family As ContentFamily
    Dim checkFamily As ContentFamily
    For Each checkFamily In hexHeadNode.Families
        Set family = checkFamily
        
        Dim oContentTableColumns As ContentTableColumns
        Set oContentTableColumns = family.TableColumns
        
        ' Check if the column already exists
        Dim columnExists As Boolean
        columnExists = False
        Dim oContentTableColumn As ContentTableColumn
        For Each oContentTableColumn In oContentTableColumns
            If oContentTableColumn.InternalName = "Material_General" Then
                columnExists = True
                Exit For
            End If
        Next
        
        ' Add the column if it doesn't exist
        If Not columnExists Then
            Dim oNewCol As ContentTableColumn
            Set oNewCol = oContentTableColumns.Add("Material_General", "Material - General", kStringType)
        End If
        
        ' Modify cell values
        Dim oRow As ContentTableRow
        For Each oRow In family.TableRows
            ' Cell value of new column
            Select Case oRow.Item("Material").Value
                Case "304L", "316L", "304 SS"
                    oRow.Item("Material_General").Value = "Stainless Steel"
                Case "CS", "ZP", "Steel", "NICKEL PLATED", "FORGED STEEL"
                    oRow.Item("Material_General").Value = "Steel"
                Case "ALUMINUM"
                    oRow.Item("Material_General").Value = "Aluminum"
                Case "Brass"
                    oRow.Item("Material_General").Value = "Brass/Bronze"
                Case "CPVC", "PVC"
                    oRow.Item("Material_General").Value = "Plastic"
                Case "GALV"
                    oRow.Item("Material_General").Value = "Galvanized"
                Case "FIBERGLASS"
                    oRow.Item("Material_General").Value = "Fiberglass"
            End Select
        Next
        
        ' Save changes
        Call family.Save
    Next

End Sub

 

0 Likes
Accepted solutions (1)
459 Views
1 Reply
Reply (1)
Message 2 of 2

KWarrenCA
Advocate
Advocate
Accepted solution

I was able to figure it out. Using the following code will add a custom property for the column.

' Set the custom property using a different method
                        Dim propSetId As String
                        Dim propIdentifier As Variant
                        propSetId = "Custom"
                        propIdentifier = "Material - General"
                        Call oNewCol.SetPropertyMap(propSetId, propIdentifier)
                    End If
0 Likes