you can use below code to export to selected folder with part number placed in dxf file:
Imports System.Windows.Forms
Dim ass As AssemblyDocument = ThisDoc.Document
On Error Resume Next
OpenAt = "C:\" ' give your own starting location
Dim dialog = New FolderBrowserDialog() ' declare folder picker
dialog.SelectedPath = OpenAt ' give starting location
If DialogResult.OK = dialog.ShowDialog() Then ' show folder picker and if button "ok was clicked export dxf's to picked location
For Each ofile As Document In ass.AllReferencedDocuments
dxffilename = ""
If ofile.ComponentDefinition.Type = kSheetMetalComponentDefinitionObject Then
Dim oSheetMetalCompDef As SheetMetalComponentDefinition = ofile.ComponentDefinition
Dim fp As FlatPattern
If oSheetMetalCompDef.HasFlatPattern = False Then
oSheetMetalCompDef.Unfold
oSheetMetalCompDef.FlatPattern.ExitEdit
End If
fp = oSheetMetalCompDef.FlatPattern
nnname = ofile.PropertySets.Item(3).Item("Part Number").Value
dxffilename =dialog.SelectedPath & "\" & nnname &".dxf"
fp.Edit()
Dim oSketch As PlanarSketch
Dim oSketches As PlanarSketches
Dim oTextBox As Inventor.TextBox
oSketches = fp.Sketches
Dim oFace As Face = fp.TopFace
Dim oTransGeom As TransientGeometry = ThisApplication.TransientGeometry
oSketch = oSketches.Add(oFace, False)
If oSketch.NaturalAxisDirection = True Then
MessageBox.Show(oSketch.NaturalAxisDirection, "Title")
oTextBox = oSketch.TextBoxes.AddFitted(oTransGeom.CreatePoint2d(0.5, 1.2), nnname)
End If
If oSketch.NaturalAxisDirection = False Then
oTextBox = oSketch.TextBoxes.AddFitted(oTransGeom.CreatePoint2d(0.5 + 6.4, -1.2), nnname)
oTextBox.Rotation = 4 * Math.Atan(1)
End If
oTextBox.ConvertToGeometry("dim")
oSketch.ExitEdit()
Dim oDataIO As DataIO = ofile.ComponentDefinition.DataIO
Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=R12&SimplifySplines=true&FeatureProfilesUpLayerCOLOR=255;255;0&InvisibleLayers=IV_BEND;IV_BEND_DOWN;IV_TANGENT;IV_ARC_CENTERS;IV_FEATURE_PROFILES_DOWN;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ROLL_TANGENT;IV_ALTREP_BACK;IV_ROLL;"
oDataIO.WriteDataToFile(sOut, dxffilename)
oSketch.Delete
End If
Next
End If