Hi @j_chaissonQB25Y
Here is a method to be run in a CC part file that contains a ND column, any ANSI pipe Fitting. The function will return the current size and the sub will get all ND's.
Sub Main
a = GetND()
MessageBox.Show(a, "Title")
GetAllND()
End Sub
Function GetND() As String
Dim doc As PartDocument = ThisDoc.Document
Dim oCC As ContentCenter = ThisApplication.ContentCenter
Dim propSet As PropertySet = doc.PropertySets.Item("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")
'Get FamilyId property.
Dim familyId As Inventor.Property = propSet.Item("FamilyId")
'Get Family.
Dim oContentFamily As ContentFamily = oCC.GetContentObject("v3#" & familyId.Value & "#")
' Get MemberId property
Dim strMemberId As String = propSet("MemberId").Value
'Get Current Row
Dim oCurrentTableRow As ContentTableRow = oCC.GetContentObject("v3#" & familyId.Value & "#" & strMemberId)
Dim NDCol As ContentTableColumn
Dim ND As String
'Set the column criteria.
Try
NDCol = oContentFamily.TableColumns.Item("ND")
ND = oCurrentTableRow.GetCellValue(NDCol)
Catch
End Try
Return ND
End Function
Sub GetAllND()
Dim NDList As New List (Of String)
Dim doc As PartDocument = ThisDoc.Document
Dim oCC As ContentCenter = ThisApplication.ContentCenter
Dim propSet As PropertySet = doc.PropertySets.Item("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")
'Get FamilyId property.
Dim familyId As Inventor.Property = propSet.Item("FamilyId")
'Get Family.
Dim oContentFamily As ContentFamily = oCC.GetContentObject("v3#" & familyId.Value & "#")
'Get Current Row
For Each oCurrentTableRow As ContentTableRow In oContentFamily.TableRows
Dim NDCol As ContentTableColumn
Dim ND As String
'Set the column criteria.
Try
NDCol = oContentFamily.TableColumns.Item("ND")
ND = oCurrentTableRow.GetCellValue(NDCol)
NDList.Add(ND)
Catch
End Try
Next
d0 = InputListBox("Prompt", NDList, d0, Title := "Title", ListName := "List")
End Sub
And here is how you would use change a part in the assembly with 3 variable criteria to select a member row. The criteria is all manually input so you will need to ensure your family contains this data.
'https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/change-length-of-a-content-center-file-with-ilogic/td-p/9512570
Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oCC As ContentCenter = ThisApplication.ContentCenter
Dim oCCmember As ComponentOccurrence
'[Select Components
Dim comps As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim comp As Object
'Set a reference to the select set of the active document.
Dim oSelectSet As SelectSet = ThisApplication.ActiveDocument.SelectSet
If oSelectSet.Count = 0 Then ' Check to make sure items were pre selected in browser pane or windowing compoonents.
'[Selecting Component using Pick.
While True
comp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,"Select a component to add to the folder, Press Esc when Complete")
'If nothing gets selected then we're done.
If IsNothing(comp) Then Exit While
comps.Add(comp)
End While
']
'Allow the user to select manually occurrences in advance of running the rule.
ElseIf oSelectSet.Count > 0 Then
For Each comp In oSelectSet
If TypeOf comp Is ComponentOccurrence
comps.Add(comp)
Else
End If
Next
'[Pause Inventor between selections
'https://ekinssolutions.com/selecting-multiple-entities-using-pick-in-inventor/
System.Windows.Forms.Application.DoEvents()
System.Threading.Thread.Sleep(300)
System.Windows.Forms.Application.DoEvents()
']
End If
Dim NDList As String() = {"2", "3", "4", "5", "6" }
Dim ND As String = InputListBox("Choose a ND", NDList, "2", Title := "Change Dia", ListName := "Dia")
If ND = Nothing Then : MessageBox.Show("Exiting", "Title") : Return :End If
Dim SchList As String() = {"10", "40", "Current"}
Dim Sch As String = InputListBox("Choose a Sch", SchList, "Current", Title := "Change Sch", ListName := "Sch")
If Sch = Nothing Then : MessageBox.Show("Exiting", "Title") : Return :End If
Dim MatList As String() = {"Steel, Wrought", "Aluminum", "Current" }
Dim Mat As String = InputListBox("Choose a Mat", MatList, "Current", Title := "Change Mat", ListName := "mat")
If Mat = Nothing Then : MessageBox.Show("Exiting", "Title") : Return :End If
For Each comp In comps
oCCmember = comp
Dim propSet As PropertySet = oCCmember.Definition.Document.PropertySets.Item("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")
'Get FamilyId property.
Dim familyId As Inventor.Property = propSet.Item("FamilyId")
'Get Family.
Dim oContentFamily As ContentFamily = oCC.GetContentObject("v3#" & familyId.Value & "#")
' Get MemberId property
Dim strMemberId As String = propSet("MemberId").Value
'Get Current Row
Dim oCurrentTableRow As ContentTableRow = oCC.GetContentObject("v3#" & familyId.Value & "#" & strMemberId)
Dim NDCol As ContentTableColumn
Dim SchCol As ContentTableColumn
Dim MatCol As ContentTableColumn
Dim oNewMember As String
Dim ee As MemberManagerErrorsEnum
'Set the column criteria.
Try
NDCol = oContentFamily.TableColumns.Item("ND")
Catch
End Try
Try
SchCol = oContentFamily.TableColumns.Item("SN")
If Sch = "Current" Then
'Get current schedule or have seperate list.
Sch = oCurrentTableRow.GetCellValue(SchCol)
End If
Catch
End Try
Try
MatCol = oContentFamily.TableColumns.Item("MATERIAL")
If Mat = "Current" Then
'Get current schedule or have seperate list.
Mat = oCurrentTableRow.GetCellValue(MatCol)
End If
Catch
End Try
'Get Row.
For Each oContentTableRow As ContentTableRow In oContentFamily.TableRows
If Not SchCol Is Nothing Then
'Set the criteria for row selection
If oContentTableRow.GetCellValue(NDCol) = ND AndAlso oContentTableRow.GetCellValue(SchCol) = Sch AndAlso oContentTableRow.GetCellValue(MatCol) = Mat Then
Try
oNewMember = oContentFamily.CreateMember(oContentTableRow, ee, "Some error occured", , False, )
oCCmember.Replace(oNewMember, True)
Catch
Logger.Info("ERROR")
End Try
oCCmember.Replace(oNewMember, True)
End If
ElseIf SchCol Is Nothing Then
If oContentTableRow.GetCellValue(NDCol) = ND AndAlso oContentTableRow.GetCellValue(MatCol) = Mat Then
Try
oNewMember = oContentFamily.CreateMember(oContentTableRow, ee, "Some error occured", , False, )
oCCmember.Replace(oNewMember, True)
Catch
Logger.Info("ERROR")
End Try
End If
End If
Next
If String.IsNullOrEmpty(oNewMember) Then
MessageBox.Show("No matching row found", "Title")
End If
'oDoc.Update
oCCmember.Parent.Document.Update
Next
As for the dynamic component box population you would need to recheck each list and check it is a valid value by checking its value and its row index. Gets fairly messy.
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan