I don't know anything about macros and I'd like to know if it's possible to make a DXF export macro that exports all the sheets of a drawing in separate files keeping the names of the sheets.
After searching on the forum I found this topic with the macro attached, which is what I'm looking for in principle, only it does PDFs and not DXFs:
Could a good soul of the forum modify this macro for me to replace the PDF with the DXF. Will the macro keep the SolidWorks "save as" options that I use when I do it manually, such as using a projection file?
The "pdf_page_par_page.swp" macro creates 1 file per drawing sheet and includes in the PDF file name the name of the drawing file + the name of the sheet
For example, if the drawing file is called "TOTO" and has 2 sheets, "PLAN" and "Rep A", the PDF macro does:
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim sPathname As String
Dim vSheetName As Variant
Dim nErrors As Long
Dim nWarnings As Long
Dim i As Long
Dim bRet As Boolean
Dim lParam As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
lParam = swApp.GetUserPreferenceIntegerValue(swDxfMultiSheetOption)
'Changement paramétrage export dxf si différent de feuille active
If lParam <> 0 Then
bRet = swApp.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swDxfMultiSheetOption, swDxfMultisheet_e.swDxfActiveSheetOnly)
End If
sPathname = swModel.GetPathName
sPathname = Left(sPathname, Len(sPathname) - 7)
vSheetName = swDraw.GetSheetNames
For i = 0 To UBound(vSheetName)
bRet = swDraw.ActivateSheet(vSheetName(i))
bRet = swModel.SaveAs4(sPathname & "_" & vSheetName(i) & ".dxf", swSaveAsCurrentVersion, swSaveAsOptions_Silent, nErrors, nWarnings)
Next i
' Retour à la Feuille 1
bRet = swDraw.ActivateSheet(vSheetName(0))
' Remise en place du paramétrage initial
bRet = swApp.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swDxfMultiSheetOption, lParam)
End Sub