- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
iLogic for forming an Excel spreadsheet
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
Blog: hjalte.nl - github.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Duplicate post 2
Or if this helped you, please, click (like)
Regards
Alan