Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
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
Solved! Go to Solution.