12-01-2020
11:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
12-01-2020
11:56 AM
That message doesn't say much. So that does not help. but i added a try/catch block. this will show the file that is creating the problem. maybe it helps. try this rule.
Sub main() Dim doc As AssemblyDocument = ThisDoc.Document For Each oDoc As Document In doc.AllReferencedDocuments If (oDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then Continue For Try Dim fileName As String = getFileName(oDoc) Dim oCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition If oCompDef.HasFlatPattern = False Then oCompDef.Unfold() Else oCompDef.FlatPattern.Edit() End If Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=2000&BendUpLayerColor=0;0;255&BendDownLayerColor=0;0;255&InvisibleLayers=IV_TANGENT" oCompDef.DataIO.WriteDataToFile(sOut, fileName) oCompDef.FlatPattern.ExitEdit() Catch ex As Exception MsgBox("Exception was thrown while exporting file: " & oDoc.FullDocumentName ) End Try Next End Sub Private Function getFileName(oDoc As PartDocument) As String Dim fileNameDoc = System.IO.Path.GetFileName(oDoc.FullFileName) Dim partNumber = iProperties.Value(fileNameDoc, "Project", "Part Number") Dim thickness As Double = Parameter(fileNameDoc, "Thickness") thickness = Math.Round(thickness * 10) Dim newFileName As String = String.Format("{0}_{1}",partNumber, thickness) Return IO.Path.Combine("c:\temp\", newFileName) End Function
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