- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.