Exporting DXF from Autodesk Inventor with Text Engraving

autodesk-inventor-professional-badge-2048px.jpg

After sharing my rough solution in the forum, I thought I would provide a more thorough explanation of how to export DXF files from Inventor with a text that typically contains the Equipment ID or other information you wish to send to other programs.

What's the issue here?

 

The Mark tool that Inventor added as a feature works wonders for engraving DXF files. While this is great for geometry, though, it exports the text engraving also as geometry. But what if you need the text engraving to stay as text in the DXF files??

 

The layers are the key:

When exporting DXF, you need to turn off and on the needed layers that will show in the DXF file. In Inventor 2025, a new layer was added that will help up here. This is the "IV_UNCONSUMED_SKETCH_CONSTRUCTION". As the name implies, it contains all the construction lines that show in the flat pattern. 

 

The end result:

Before we go to the specifics, let's see what the desired result would be. We want a flat pattern that contains only the engraving text and construction lines.

 

The solution:

Let's say you have a sheet metal part with a sketch that contains text. The best practice here is to name this sketch, especially if we will use API to export the DXF. Let's name this sketch "Equipment_ID".

 

First of all, if there is a “Mark” feature on that specific sketch in the part, delete it, but keep its sketch. This would interfere with the wanted result.

 

As I mentioned, keep a consistent sketch name; usually we have multiple files to export DXF, so we often use code to export derivatives fast. If the engraving text in the sketch is dynamic (order & part number, for example), create a text user parameter and keep the naming consistency there too.

 

Inside the engraving sketch, we have a text box with our text. Keep the "Text Box" on. We want that bounding box with construction lines. You can format the text as you like but keep the "Single Line Text" button turned off.

Inventor_os0cAayrbx.png

 

Two paths to take here:

 

Path 1:

The simplest way is to constrain and dimension the text box with any edge or workplane. Just keep in mind that every line and projected line should be a construction line! Do NOT project any points/workpoints. If there are any, delete them. That includes the origin point. 

 

Path 2:

But what if I need to constrain the text box from a point??

 

  1. Create a new sketch in the plane you want the engraving to be. We will name it "Reference_Sketch" and it should be above the “Equipment_ID” sketch in the model tree.
  2. Inside, add a rectangle in the place that you want the engraving to be. You can freely and roughly position this rectangle from any edge, plane, or point. Dimension also the rectangle. Just make it roughly big enough to contain the engraving text.
  3. With the “Reference" Sketch visible, open the “Equipment_ID” Sketch. Press “Project Geometry”, hold down the “Shift” key to project the lines as construction lines, and click on every line of the rectangle. (Of course you can convert the lines later to construction, or from Application Options, you can choose to project all lines as construction.)
  4. Turn off the “Reference" Sketch visibility, and you should now see a simple rectangle with construction lines.
  5. You all have to do now is constraint the lines of the text box with the lines of the rectangle using the Collinear Constraint.
  6. The result should be a rectangle with construction lines and the engraving text. No other line or point should be visible here.
    msedge_r89AZIVnsa.png

 

No matter which path you choose, the result should be the same. The last step is to right-click the "Equipment_ID" sketch and select "Copy to Flat Pattern". If you use ilogic or other software to export the DXF files, I recommend adding this step to the code.

 

Example with C#:

 

 

 

try
{
    // Copy the engraving sketch to the flat pattern if provided
    PlanarSketch engravingSketchObj = ((PartDocument)doc).ComponentDefinition.Sketches[engravingSketch];

    foreach (Inventor.TextBox textBox in engravingSketchObj.TextBoxes)
    {
        // Create a color with RGB values for yellow
        Inventor.Color yellowColor = invApp.TransientObjects.CreateColor(255, 255, 0);

        // Assign the yellow color to the TextBox
        textBox.Color = yellowColor;
    }

    // Copy the modified sketch to the flat pattern
    engravingSketchObj.CopyToFlatPattern = true;
}
catch (Exception)
{
    // Engraving sketch not found or unable to copy to flat pattern
}

try
{
    doc.Update2();

    DataIO oDataIO = doc.ComponentDefinition.DataIO;

    oDataIO.WriteDataToFile("FLAT PATTERN DXF?AcadVersion=2004" +
                            "&OuterProfileLayer=IV_OUTER_PROFILE" +
                            "&InteriorProfilesLayer=IV_INTERIOR_PROFILE" +
                            "&UnconsumedSketchesLayer=GO_ID" +
                            "&TextHandling=TextAsText" +
                            "&InvisibleLayers=IV_TANGENT;IV_BEND;IV_ARC_CENTERS;IV_BEND_DOWN;IV_UNCONSUMED_SKETCH_CONSTRUCTION",
                            System.IO.Path.GetDirectoryName(fullFilePath)
                            + @"\" + orderNumber + fullFilePath.Replace(System.IO.Path.GetDirectoryName(fullFilePath)
                            + @"\", "").Replace(".ipt", ".dxf"));

    doc.Save2();
}
catch (Exception ex)
{
    MessageBox.Show("Error exporting DXF: " + ex.ToString());
}

 

 

 

 

Example with iLogic:

 

 

 

' Locate the engraving sketch
			Dim engravingSketchName As String = "Equipment_ID"
			Dim engravingSketch As PlanarSketch = Nothing
			
			For Each oSketch In oCompDef.Sketches
			    If oSketch.Name = engravingSketchName Then
			        engravingSketch = oSketch
			        Exit For
			    End If
			Next
			
			If engravingSketch IsNot Nothing Then
			    ' Optional: Change text color in the sketch
			    For Each textBox As Inventor.TextBox In engravingSketch.TextBoxes
			        Dim yellowColor As Inventor.Color = ThisApplication.TransientObjects.CreateColor(255, 255, 0)
			        TextBox.Color = yellowColor
			    Next
			
			    ' Copy the sketch to the flat pattern
			    engravingSketch.CopyToFlatPattern = True
			End If

            ' Export DXF
            Dim oDataIO As DataIO = oCompDef.DataIO
            Dim dxfFileName As String = IO.Path.GetDirectoryName(DxfPartDoc.FullFileName) & "\" & Ordernumber & "-" & DxfPartNumber & ".dxf"
            oDataIO.WriteDataToFile("FLAT PATTERN DXF?AcadVersion=2004" &
                                    "&OuterProfileLayer=IV_OUTER_PROFILE" &
                                    "&InteriorProfilesLayer=IV_INTERIOR_PROFILE" &
                                    "&UnconsumedSketchesLayer=GO_ID" &
                                    "&TextHandling=TextAsText" &
                                    "&InvisibleLayers=IV_TANGENT;IV_BEND;IV_ARC_CENTERS;IV_BEND_DOWN;IV_UNCONSUMED_SKETCH_CONSTRUCTION", dxfFileName)