export partlist to excel sorting problem

export partlist to excel sorting problem

ultimateconjoe
Participant Participant
607 Views
5 Replies
Message 1 of 6

export partlist to excel sorting problem

ultimateconjoe
Participant
Participant

Hi there,

 

for a dead weight calculation, i want to export the main assembly partlist to excel. This main assembly consists of several subassemblies. When exporting to excel i want to have the following structure:

 

1 - subassembly 1   -   2000 kg   

2 - subassembly 2  -  1200 kg 

 

etc......

 

then these subassemblies need to be converted to seperate list , like :

 

subassembly 1

 

1 - part1   -   200 kg

2- part2  - 100 kg

3 - subassembly 4 - 75 kg 

 

etc...

 

the problem is to get the subassembly 4 in a seperate list again. 

 

i think i have to write some sort of recursive routine.

 

Somebody got a solution for this.?

 

Thnx!!!

 

Greetz Chris

 

0 Likes
608 Views
5 Replies
Replies (5)
Message 2 of 6

bradeneuropeArthur
Mentor
Mentor
Hi,

Are you talking about the Partslist or about the Bill of Material?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 6

ultimateconjoe
Participant
Participant

Hi,

 

it's about the partlist....

 

 

Chris

0 Likes
Message 4 of 6

bradeneuropeArthur
Mentor
Mentor
Could you upload your code so we can modify it?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 6

ultimateconjoe
Participant
Participant

It's little bit of messy code, but it's doable...:)

 

 

' iterate the partlist rows

For i = counter To oPartslist.PartsListRows.Count

orow = oPartslist.PartsListRows.Item(i)


'write values for the different columns
For j = 1 To oPartslist.PartsListColumns.Count
Dim ocell As Inventor.PartsListCell
ocell = orow.Item(j)


If j = 1 Then
Me.DataGridView1.Rows(i - 1).Cells(0).Value = ocell.Value
End If

 

If j = 2 Then
Me.DataGridView1.Rows(i - 1).Cells(2).Value = ocell.Value
End If

 

If j = 3 Then
Me.DataGridView1.Rows(i - 1).Cells(1).Value = ocell.Value
End If

 

If j = 6 Then
Me.DataGridView1.Rows(i - 1).Cells(6).Value = ocell.Value
End If

 

If j = 7 Then
Me.DataGridView1.Rows(i - 1).Cells(4).Value = ocell.Value

 

'multiply the value from cell 2 with the value from cell 4


weight1 = Convert.ToDecimal(DataGridView1.Rows(i - 1).Cells(2).Value)
weight3 = oPartslist.PartsListRows(i).Item(7).Value.ToString

 

'delete the kg from value


weight3 = weight3.Substring(0, weight3.Length - 2)
weight2 = Convert.ToDouble(weight3)

totweight = weight1 * weight2

DataGridView1.Rows(i - 1).Cells(5).Value = totweight & " kg"

 

'add the weight to the total weight
totaal = totaal + totweight


End If

 

If j = 8 Then
If oPartslist.PartsListRows(i).Item(j).Value = "" Then
Me.DataGridView1.Rows(i - 1).Cells(3).Value = "-"
Else
Me.DataGridView1.Rows(i - 1).Cells(3).Value = ocell.Value
End If
End If


Next j

 

' check to see if it's a subassembly


If orow.Expandable = True Then

 

'get the number of rows for the subassembly

loopcount = getloopcount(orow)

 

'write the values to the gridview

writesub(loopcount, i)

 

Me.DataGridView1.Rows(i - 1).Cells(7).Value = "SEE DETAILS"
End If

 

Me.ProgressBar1.PerformStep()

 

Next i

 

'write total weight to gridview
Me.DataGridView1.Rows(begincount).Cells(4).Value = "TOTAL : "
Me.DataGridView1.Rows(begincount).Cells(5).Value = totaal & " kg"
Me.DataGridView1.Rows(begincount).Cells(4).Style.Font = New System.Drawing.Font(Control.DefaultFont, FontStyle.Bold)
Me.DataGridView1.Rows(begincount).Cells(5).Style.Font = New System.Drawing.Font(Control.DefaultFont, FontStyle.Bold)
Me.DataGridView1.Rows(begincount).DefaultCellStyle.BackColor = Color.DarkGray

 

End Sub


Sub writesub(loopcount As Integer, i As Integer)
Dim startitem As Integer

'remember the startrow
startitem = i

' read the rows in subassembly
For a = 0 To loopcount

orow = oPartslist.PartsListRows.Item(i)


'Write the different values for the columns
For j = 1 To oPartslist.PartsListColumns.Count

 

If j = 1 Then
Me.DataGridView1.Rows(startrow).Cells(0).Value = oPartslist.PartsListRows(i).Item(j).Value


If a = 0 Then
Me.DataGridView1.Rows(startrow).Cells(0).Style.Font = New System.Drawing.Font(Control.DefaultFont, FontStyle.Bold)
End If


End If

 

If j = 2 And a > 0 Then
Me.DataGridView1.Rows(startrow).Cells(2).Value = oPartslist.PartsListRows(i).Item(j).Value
End If

 

If j = 3 Then
Me.DataGridView1.Rows(startrow).Cells(1).Value = oPartslist.PartsListRows(i).Item(j).Value


If a = 0 Then
Me.DataGridView1.Rows(startrow).Cells(1).Style.Font = New System.Drawing.Font(Control.DefaultFont, FontStyle.Bold)
End If

 

End If

 

If j = 6 And a > 0 Then
Me.DataGridView1.Rows(startrow).Cells(6).Value = oPartslist.PartsListRows(i).Item(j).Value
End If

 

If j = 7 And a > 0 Then
Me.DataGridView1.Rows(startrow).Cells(4).Value = oPartslist.PartsListRows(i).Item(j).Value
End If

 

If j = 8 And a > 0 Then
If oPartslist.PartsListRows(i).Item(j).Value = "" Then
Me.DataGridView1.Rows(startrow).Cells(3).Value = "-"
Else
Me.DataGridView1.Rows(startrow).Cells(3).Value = oPartslist.PartsListRows(i).Item(j).Value
End If
End If

 

Next j

 

If a > 0 Then
weight1 = Convert.ToInt32(DataGridView1.Rows(startrow).Cells(2).Value)
weight3 = oPartslist.PartsListRows(i).Item(7).Value.ToString

If Not weight3 = "" Then
weight3 = weight3.Substring(0, weight3.Length - 2)
weight2 = Convert.ToDouble(weight3)
totweight = weight1 * weight2
totalsub = totalsub + totweight
DataGridView1.Rows(startrow).Cells(5).Value = totweight & " kg"
End If
End If


'this is the part where it goes wrong......!!

If orow.Expandable = True And a > 0 Then

loopcount = getloopcount(orow)

'remember the row where we left
rowexit = startrow

' add extra rows for writing the values for the subassembly
startrow = startrow + extrarow

writesub(loopcount, i)

i = i + 1

startrow = startrow + 1

startrow = rowexit
Else

startrow = startrow + 1


i = i + 1
End If

 

 

Next

orow = oPartslist.PartsListRows.Item(startitem)

If orow.Expanded = True Then

orow.Expanded = False

startrow = startrow + extrarow
Else startrow = startrow + 1
End If

 

End Sub

 

Function getloopcount(orow As Inventor.PartsListRow)

countbefore = oPartslist.PartsListRows.Count

orow.Expanded = True

countafter = oPartslist.PartsListRows.Count

 

countsubtracted = countafter - countbefore

extrarow = countsubtracted + 1

ListBox1.Items.Add(extrarow)


Return countsubtracted


End Function

0 Likes
Message 6 of 6

ultimateconjoe
Participant
Participant

Ok,

 

i will put it in another way then.....Smiley Happy 

 

I want to convert this partlist  :

partlist.jpg

 

 

into this , with vb.net :

excel output.jpg

 

 

So if an item in the main assembly consists of a subassembly, it has to been written in a seperate row..... and so on...!

 

 

I hope someone can help me...!

 

Thnx!

 

Geertz Chris

 

 

0 Likes