iLogic for forming an Excel spreadsheet

iLogic for forming an Excel spreadsheet

negutorthik
Contributor Contributor
329 Views
2 Replies
Message 1 of 3

iLogic for forming an Excel spreadsheet

negutorthik
Contributor
Contributor

Help a beginner to complete the rule. You need to add a column in Excel the amount of sheet material. I haven't slept for the second day.Nothing works out. I hope for your help

 

 

'____Create and write to a text file_________________
Try
extension = ".csv"
If (System.IO.File.Exists(ThisDoc.PathAndFileName(False) + extension) = True) Then
System.IO.File.Delete(ThisDoc.PathAndFileName(False) + extension)
End If

sBom = ThisDoc.Document.ComponentDefinition.BOM
sBom.PartsOnlyViewEnabled = True
sBOMView = sBom.BOMViews.Item("Только детали")
Catch
MessageBox.Show("Ошибка 1", "Ошибка")
End Try
Try
For Each sRow In sBOMView.BOMRows
Try
sCompDef = sRow.ComponentDefinitions.Item(1)

If sCompDef.Type = ObjectTypeEnum.kSheetMetalComponentDefinitionObject Then
Try
If sCompDef.HasFlatPattern = True Then
oFlat = sCompDef.FlatPattern
oStr = sCompDef.Document.DisplayName
oStr = oStr + ";" + (oFlat.Length * 10).ToString
oStr = oStr + ";" + (oFlat.Width * 10).ToString
oStr = oStr + ";" + (sCompDef.Thickness.Value * 10).ToString
oStr = oStr + ";" + (sCompDef.Material.Name).ToString
System.IO.File.AppendAllText(ThisDoc.PathAndFileName(False) + extension, oStr + vbNewLine, System.Text.Encoding.Default)
End If
Catch
MessageBox.Show("Ошибка 2", "Ошибка")
End Try
End If
Catch
MessageBox.Show("Ошибка 3", "Ошибка")
End Try
Next
Catch
MessageBox.Show("Ошибка 4", "Ошибка")
End Try
Try
ThisDoc.Launch(ThisDoc.PathAndFileName(False) + extension)
Catch
MessageBox.Show("Ошибка открытия файла", "Ошибка")
End Try

0 Likes
Accepted solutions (1)
330 Views
2 Replies
Replies (2)
Message 2 of 3

blandb
Mentor
Mentor
Accepted solution

Have you looked into this:

 

http://inventortrenches.blogspot.com/search?q=excel 

 

I have used some of the items to generate the columns as needed upon export.

Autodesk Certified Professional
0 Likes
Message 3 of 3

A.Acheson
Mentor
Mentor

Hi @negutorthik 

In your code you are not using excel at all and or your not using the BOM export method either. Can you share an image of what the data in the BOM looks like and what the finished excel looks like from your manual workflow? 

 

Here is an example of exporting each row from the parts only BOMView. If you want to filter sheetmetal parts then add that in the code like you have done previously. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes