11-27-2020
11:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-27-2020
11:48 AM
I guessit was to later yesterday. there i found the bug and fixed it. Check the code below. An other thing that i forgot to mention. i multiply the thickness by 10. I did that because its better if you dont use points in file names. For example if your part would be 1.5mm thick you would get a file name like "PartNumber_1.5.dxf". this code will translate that to "PartNumber_15.dxf"
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 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() 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