iLogic for forming an Excel spreadsheet

iLogic for forming an Excel spreadsheet

negutorthik
Contributor Contributor
228 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
229 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor

try this:

 

Dim extension = ".csv"

Try

    If (System.IO.File.Exists(ThisDoc.PathAndFileName(False) + extension)) Then
        System.IO.File.Delete(ThisDoc.PathAndFileName(False) + extension)
    End If

    Dim sBom = ThisDoc.Document.ComponentDefinition.BOM
    sBom.PartsOnlyViewEnabled = True
    Dim sBOMView = sBom.BOMViews.Item("Только детали")

    For Each sRow As BOMRow In sBOMView.BOMRows
        Try
            Dim sCompDef = sRow.ComponentDefinitions.Item(1)

            If sCompDef.Type = ObjectTypeEnum.kSheetMetalComponentDefinitionObject Then
                Try
                    If sCompDef.HasFlatPattern Then
                        Dim oFlat = sCompDef.FlatPattern
                        Dim 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
                        oStr = oStr + ";" + (sRow.ItemQuantity).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

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 3

A.Acheson
Mentor
Mentor

Hi @negutorthik 

It looks like you have posted multiple messages with the same topic. Please try not to do that as you end up with the same answer multiple times or no responses at all . If you need further assistance just respond to the same post which will bump it to the top. If possible include further information and the attempted code with error messages and a description of what the problem is and you will get better help to the questions asked.

Duplicate post1

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/need-help-exporting-sheet-material-t...

 

Duplicate post 2

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-for-forming-an-excel-spreadsh...

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