Macro export of a dxf drawing view

Hello

I searched in different forums (French and English) but I can't find the answer.

We use DXF export for a supplier that does laser cutting exclusively, but we want to add an "engraving" with the plan number. To do this, our supplier requires that the text to be engraved be present in the dxf under a "T" layer (for his machine is automatic).
For the moment, the method used is as follows:

  1. Creating a drawing view in the desired orientation
  2. Rename the saw to "DXF"
  3. Added a note related to the custom property "Plan No."
  4. Selecting the view is "save views as" at the very bottom of the FeatureManager
  5. With the custom projection option, we use a projection file that allows us to save the lines of the model in a "0" layer and the notes in a "T" layer

For the moment it's working really well.
Except that, I'd like to automate it with a macro.
Knowing that we already have a macro to save the drawing in PDF + DWG format, and the model in STEP format (by adding the clues in the file name).
The goal would be to have a macro for the dxf and integrate it into our existing macro by saying "if the "DXF" view exists, then we save it in DXF format using the projection options etc etc.

Does it seem feasible to you? The problem is that I can't find any trace of a macro to record a VUE in DXF format.

Hello
I suggest you copy the view to a new temporary sheet (with an empty flat background it won't appear in the dxf)

Hello;
You can hide the other views, save in DXF and then show them again for example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Diagnostics;
//using System.Windows.Forms;

using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;


namespace Macro1
{
    public partial class SolidWorksMacro
    {
        public void Main()
        {
            ModelDoc2 swDoc = ((ModelDoc2)(swApp.ActiveDoc));
            ModelDocExtension swDocExt = swDoc.Extension;
            DrawingDoc swDrawing = (DrawingDoc)swDoc;
            View swView = (View)swDrawing.GetFirstView();
            swView = (View)swView.GetNextView();
            bool boolstatus;
            int errors = 0;
            int warnings = 0;
            List<string> nomDesVuesAMontrer = new List<string>();


            //cacher les vues non désirées
            while (swView != null)
            {
                if (swView.Name != "DXF")
                {
                    if(swView.GetVisible() == true)
                    {
                        swView.SetVisible(false, false);
                        nomDesVuesAMontrer.Add(swView.Name);
                    }
                    
                }
                swView = (View)swView.GetNextView();
            }

            //enregistrer en DXF
            AdvancedSaveAsOptions options_save = (AdvancedSaveAsOptions)swDocExt.GetAdvancedSaveAsOptions(0);
            boolstatus = swDocExt.SaveAs3(@"C:\Users\enregistrement_DXF.dxf", 0, 0, null, options_save, ref errors, ref warnings);

            //montrer les vues comme avant
            foreach (string nom in nomDesVuesAMontrer)
            {
                swDrawing.ActivateView(nom);
                swView = (View)swDrawing.ActiveDrawingView;
                swView.SetVisible(true, false);                
            }
            return;
        }
        public SldWorks swApp;

    }
}

Hello
Below is a complement to my proposal

Sub export_view()
    Dim st As Boolean
    st = swmodel.Extension.SelectByID2("DXF", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
    If st Then
        swmodel.EditCopy
        swdraw.NewSheet4 "tmp", 0, 13, 1, 1, False, "", 0, 0, "", 0, 0, 0, 0, 0, 0
        swmodel.Paste
        'save as dxf
        'delete temp_sheet
    Else
    End If
End Sub

<< I would like to point out that the drilling tables linked to the view are also copied, to be managed according to the need >>