<?xml encoding=”UTF-8″>By Xiaodong Liang
In Inventor UI, we can edit cell, add new columns to the family table. In API, there are equivalent objects and methods.
The presumption is the family has been copied to your custom library which is read-write enabled.
The demo below dumps gets the specific family, dumps all columns name, adds one new column whose value is string type. Finally it fills in the column with the value ‘dummy’ for all rows. It also intentionally modifies the value of column ‘Grip Len’ of all rows.
Do not forget to save the family after any modification.
Sub ModifyFamilyTable()
Dim oContentCenter As ContentCenter
Set oContentCenter = ThisApplication.ContentCenter
Dim hexHeadNode As ContentTreeViewNode
Set hexHeadNode = ThisApplication.ContentCenter.TreeViewTopNode.ChildNodes.Item("Fasteners").ChildNodes.Item("Bolts").ChildNodes.Item("Hex Head")
Dim family As ContentFamily
Dim checkFamily As ContentFamily
For Each checkFamily In hexHeadNode.Families
If checkFamily.DisplayName = "DIN EN 24016" Then
Set family = checkFamily
Exit For
End If
Next
Dim oContentTableColumns As ContentTableColumns
Set oContentTableColumns = family.TableColumns
'dump all columns
Dim oContentTableColumn As ContentTableColumn
For Each oContentTableColumn In oContentTableColumns
Debug.Print "internal name:" & oContentTableColumn.InternalName & "<<<<>>>>display heading:" & oContentTableColumn.DisplayHeading
Next
'add one column
Dim oNewCol As ContentTableColumn
Set oNewCol = oContentTableColumns.Add("myHexHeadNewCol", "My Hex Head New Property", kStringType)
'modify cell
Dim oRow As ContentTableRow
For Each oRow In family.TableRows
'cell value of new column
oRow.Item("myHexHeadNewCol").Value = "dummy"
'cell value of a built-in column named 'GD1', display name: "Pitch Diameter"
'e.g. double it
'use internal name of the column
oRow.Item("KLG").Value = oRow.Item("KLG").Value * 2
Next
'save change
Call family.Save
End Sub




Leave a Reply