Parts List Hide Children

Parts List Hide Children

KWarrenCA
Advocate Advocate
238 Views
3 Replies
Message 1 of 4

Parts List Hide Children

KWarrenCA
Advocate
Advocate

I'm trying to modify the following code to only hide parts that are apart of an expandable assembly but not the main assembly. I also don't want to look at the item number because some assemblies we renumber and some wont have the "." in the number.

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList As PartsList
Dim oRow As PartsListRow

For Each oPartsList In oDrawDoc.ActiveSheet.PartsLists
	Try
		For Each oRow In oPartsList.PartsListRows
			Try
				If oRow.Expanded Then
					Visible = False
				Else
				End If

			Catch
			End Try
	Next
	Catch
	End Try
	Next

After Expanding and hiding rowsAfter Expanding and hiding rowsPrior to expanding and hiding rows.Prior to expanding and hiding rows.

0 Likes
239 Views
3 Replies
Replies (3)
Message 2 of 4

Andrii_Humeniuk
Advisor
Advisor

Hi @KWarrenCA .
You need to check if the Row is Expanded and if so, set Expanded = False.
Please check the iLogic code below.

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument

For Each oPartsList As PartsList In oDrawDoc.ActiveSheet.PartsLists
	Try
		For Each oRow As PartsListRow In oPartsList.PartsListRows
			With oRow
				If .Expandable Then .Expanded = False
			End With
		Next
	Catch : End Try
Next

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 4

KWarrenCA
Advocate
Advocate

@Andrii_Humeniuk so you are just taking the expanded assembly and collapsing it. I'm looking to turn the visibility of the parts off while while it still expanded and just show the the main assembly. I know its not exactly how the parts list is but this is how I'm looking to do a few parts list while we are in a transition to moving to item master in the vault so that we can have a full bom with all of the parts on the drawing cover page and then have the assemblies detailed in the drawings else where.

0 Likes
Message 4 of 4

Andrii_Humeniuk
Advisor
Advisor

Controlling the visibility of each row will take more time than the usual method of collapsing subrows. The code below makes rows invisible if they are children.

Public Sub Main()
	Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
	
	For Each oPartsList As PartsList In oDrawDoc.ActiveSheet.PartsLists
		Dim iItem As Integer = GetRowITEM(oPartsList)
		For Each oRow As PartsListRow In oPartsList.PartsListRows
			If oRow(iItem).Value.Contains(".") Then oRow.Visible = False
		Next
	Next
End Sub

Private Function GetRowITEM(ByVal oPsList As PartsList) As Integer
	Dim iItem As Integer = 1
	For i As Integer = 1 To oPsList.PartsListColumns.Count
		Select Case oPsList.PartsListColumns(i).PropertyType
		Case PropertyTypeEnum.kItemPartsListProperty : Return i
		Case PropertyTypeEnum.kItemQuantityPartsListProperty : Return i
		End Select
	Next i
	Return iItem
End Function

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes