Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic partslist expand children

Anonymous

iLogic partslist expand children

Anonymous
Not applicable

 

Hello. I was wondering if anyone could help me with this.

 

Below is the code I use to create an .IDW, create a partslist and export the partslist as EXCEL.

I need to know if I can expand all children before exporting it.

 

SyntaxEditor Code Snippet

v_RutaYNombre= ThisDoc.PathAndFileName(False)
Dim v_DocReferencia As Document = ThisApplication.ActiveDocument
Dim v_Plano As DrawingDocument = ThisApplication.Documents.Add(kDrawingDocumentObject, "V:\Templates\Templates 2017\INOXPASER\INOXPASER MECANIZADO ISO2768m2017.idw", True)
Dim v_Hoja As Sheet = v_Plano.ActiveSheet
Dim v_GeoTrans As TransientGeometry = ThisApplication.TransientGeometry
v_Opciones = ThisApplication.TransientObjects.CreateNameValueMap
v_ManagerEstilos = v_Plano.StylesManager
v_EstiloLista = v_ManagerEstilos.PartsListStyles.Item("BOM")
v_Plano = ThisApplication.ActiveDocument
v_Plano.SaveAs(v_RutaYNombre & "BOM.idw",False)
v_VistaSuperior = v_Hoja.DrawingViews.AddBaseView(v_DocReferencia,v_GeoTrans.CreatePoint2d(-15,0 ),.25,ViewOrientationTypeEnum.kTopViewOrientation,DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle,,,)
v_Marco= v_Hoja.Border
v_ListaPiezas = v_Hoja.PartsLists.Add(v_VistaSuperior, v_Marco.RangeBox.MaxPoint,PartsListLevelEnum.kStructuredAllLevels)
v_Hoja.PartsLists(1).Style = v_EstiloLista
v_Opciones.Value("AutoFitColumnWidth") = True
v_ListaPiezas.Export(ThisDoc.Path & "\BOM.xls", PartsListFileFormatEnum.kMicrosoftExcel,v_Opciones)
v_Plano.Close
My.Computer.FileSystem.DeleteFile(v_RutaYNombre & "BOM.idw")

I'm posting 2 images:

1 As the partslist comes with my code

1 As it should be (with all levels expanded)

Captura1.JPGCaptura2.JPG

Thanks in advance!

0 Likes
Reply
Accepted solutions (1)
787 Views
3 Replies
Replies (3)

clutsa
Collaborator
Collaborator
Accepted solution

Here's a sample of what you could do.

Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim oSheet As Sheet = doc.ActiveSheet
Dim partslist As PartsList = oSheet.PartsLists(1)
Dim oRow As PartsListRow
Dim FirstRowCount As Integer = partslist.PartsListRows.Count
Dim LastRowCount As Integer = 0
Do Until FirstRowCount = LastRowCount
	FirstRowCount = partslist.PartsListRows.Count
	For Each oRow In partslist.PartsListRows
		Try
			oRow.Expanded = True
		Catch ex As Exception
			
		End Try
	Next
	LastRowCount = partslist.PartsListRows.Count
Loop

I know you have parts of my code already in your code but you get the idea.

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Anonymous
Not applicable

Thanks man!!

Works like a charm.

0 Likes

dominiek_vanwest
Advocate
Advocate

The code from @clutsa works but if you have a big partslist it can take a while.

 

I've tried with my code below, which works a bit faster (as it goes through each line of the partslist only once).

 

Dim app As Inventor.Application = ThisApplication
Dim doc As DrawingDocument = app.ActiveDocument
Dim oSheet As Sheet = doc.ActiveSheet
Dim oPartsList As PartsList = oSheet.PartsLists(1)    
Dim oRow As PartsListRow
Dim i As Integer
Do Until i = oPartsList.PartsListRows.Count + 1
    On Error Resume Next
    oPartsList.PartsListRows(i).Expanded = True
    i = i + 1
Loop

 

However, it still doesn't work fast enough.

I have a partslist with 470 rows and my code takes about 1min15s to execute.

If I would do it manually (open partslist -> select column +/- -> right click -> Expand All Children) it takes only 5-10s.

 

Is there a way to improve speed of this?

I've also tried with Defer Updates and turn off visibility of Inventor but those didn't help.

 

Thanks in advance,

Dominiek

0 Likes