Hi, try this code to run it from an assembly, look for all reference files of sheet metal, export them to dxf without Bend lines or tangent lines. Group the sheets into folders by thickness and material. You can place a revision to your sheetmetals.
Sub Main()
Dim New_Folder_Path As String = ThisDoc.Path
Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
My.Computer.FileSystem.CreateDirectory(New_Folder_Path)
'Ask user for REV level
Dim Rev_Level As String = ""
Rev_Level = InputBox ("Enter Rev Level","Creating DXF files For Entire Assembly")
Dim Count_up As Integer = 0
Dim Gauge_Folders(12) As String
Dim Ga As String
Dim doc As Document
Dim R_Part As String
Dim oMaterial As Material
For Each doc In oAsmDoc.AllReferencedDocuments
If doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Try
R_Part = doc.DisplayName
oMaterial = doc.ComponentDefinition.Material
Gauge_Path = New_Folder_Path & "\" & Parameter(R_Part, "Thickness") & " " & oMaterial.Name
MessageBox.Show(Gauge_Path )
Try
My.Computer.FileSystem.CreateDirectory(Gauge_Path)
Catch
End Try
Call Make_DXF(doc, Rev_Level, Gauge_Path)
Catch
End Try
End If
Next
MsgBox("DXF Export Complete",,"All Done")
End Sub
Sub Make_DXF(oDoc As Document, Rev_L As String, File_Location As String)
ThisApplication.Documents.Open(oDoc.FullFileName, True)
Dim Part_Name As String = oDoc.DisplayName
Dim TestPos As Integer = 0
Dim Rev_Adder As String = ""
If Rev_L <> "" Then Rev_Adder = " REV " & Rev_L
TestPos = InStr(1, Part_Name, ".")
If TestPos <> 0 Then Part_Name = Left(Part_Name, InStr(Part_Name, ".")-1)
Dim New_Name As String = Part_Name
Dim oFilename As String = File_Location & "\" & New_Name & Rev_Adder & ".dxf"
Dim oCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If
Dim oFlatPattern As FlatPattern = oCompDef.FlatPattern
Dim oFace As Face = oFlatPattern.TopFace
Dim oCommand As CommandManager = ThisApplication.CommandManager
oCommand.DoSelect(oFace)
oCommand.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent,oFilename)
oCommand.ControlDefinitions.Item("GeomToDXFCommand").Execute2(True)
oCompDef.FlatPattern.ExitEdit
oDoc.Close
End Sub
I hope this helps your work. regards
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn