It's not actually a function. You launch a command from the API, put it will complete automatically if you set it up with a filename. Here's a function:
Public Sub ExportBottomFaceToDxf(ByVal doc As Document, ByVal app As Inventor.Application)
Dim partDoc As PartDocument = doc
Dim sheetMetalDef As SheetMetalComponentDefinition = partDoc.ComponentDefinition
If (Not sheetMetalDef.HasFlatPattern()) Then
sheetMetalDef.Unfold()
End If
Dim flatPattern As FlatPattern = sheetMetalDef.FlatPattern
flatPattern.Edit()
Dim faceToExport As Face = GetBottomFace(flatPattern)
If (faceToExport Is Nothing) Then
MessageBox.Show("Can't get the bottom face of the flat pattern for the part: " & doc.DisplayName, "Export Flat Pattern as DXF")
Else
partDoc.SelectSet.Select(faceToExport)
Dim filename As String = IO.Path.GetFileNameWithoutExtension(doc.FullFileName) + ".dxf"
app.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, IO.Path.Combine(DxfOutputFolder, filename))
Dim oCtrlDef As ControlDefinition
oCtrlDef = app.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")
oCtrlDef.Execute()
End If
flatPattern.ExitEdit()
End Sub
This uses another function GetBottomFace to find the face to be exported.
The PostPrivateEvent call sets up the "GeomToDXFCommand" command with the filename for export. Here I'm using a predefined variable DxfOutputFolder.
Mike Deck
Software Developer
Autodesk, Inc.