Export dwg multiples...?

Hello
I received a .sldprt file with a complex part and 40 configurations.
I have to extract all the dwg from several elements (5 or 200 dwg in total),
How do I automate the task?
Thank you in advance.
Another question: how to make Solidworks default the dfx/dwg export to the dfx/dwg?
:wink:

Hello

Attached is a macro that I had found and modified with the help of the group to extract all the DWGs from the configurations but the parts must be sheet metal for it to work. The macro takes the name of the configuration.

Dim swApp As Object
Option Explicit
Sub main()
'Déclarations :
Dim swApp                   As SldWorks.SldWorks
Dim swModel                 As SldWorks.ModelDoc2
Dim config                  As SldWorks.Configuration
Dim vConfNameArr            As Variant
Dim sConfigName             As String
Dim i                       As Long
Dim bShowConfig             As Boolean
Dim bRebuild                As Boolean
Dim bRet                    As Boolean
Dim FilePath                As String
Dim PathSize                As Long
Dim PathNoExtension         As String
Dim NewFilePath             As String
Dim Value_                 As String
Dim ResolvedValOut          As String
Dim cusPropMgr              As SldWorks.CustomPropertyManager
Dim wasResolved             As Boolean
Dim Error As Long
Set swApp = CreateObject("SldWorks.Application") 'Lancement de SW
Set swModel = swApp.ActiveDoc 'Récuperation du modèle actif dans SW

vConfNameArr = swModel.GetConfigurationNames 'Création de la liste des configurations
For i = 0 To UBound(vConfNameArr) 'Boucle la liste : de l'élément 0 jusqu'au nombre d'élément dans la liste (Ubound)
    Set config = swModel.GetActiveConfiguration
    Set cusPropMgr = config.CustomPropertyManager
    sConfigName = vConfNameArr(i) 'Recupère l'élément N°i de la liste
    bShowConfig = swModel.ShowConfiguration2(sConfigName) 'Affiche la configuration
    Error = cusPropMgr.Get5("TYPE", True, Value_, ResolvedValOut, wasResolved) 'Récupère la valeur de la proriété "" dans la variable "Value_"
    bRebuild = swModel.ForceRebuild3(False) 'Reconstruction du modèle
    FilePath = swModel.GetPathName 'Récupère le chemin du fichier SW
    PathSize = Strings.Len(FilePath) 'Compte le nombre de caractères du chemin
    
        PathNoExtension = Strings.Left(FilePath, PathSize - 6) 'Récupère le nom de la pièce en enlevant .Sldrt
        NewFilePath = Left(FilePath, InStrRev(FilePath, "\")) & "" & (sConfigName) & ".DWG" 'Remplace le nom par Type + Lg + Nom de la config (sans Flat pattern).dwg
        bRet = swModel.ExportFlatPatternView(NewFilePath, 0) 'Exporte le déplié
    
Next i 'Passe à la prochaine config
End Subb

export_dwg_famille_de_piece - Ac cobra with .swp fold line (29.5 KB)

3 Likes

Many thanks :slightly_smiling_face:
But what do you do with the elements that are not made of sheet metal? Because in "my" drawing there are 5 faces for which I have to extract the DWGs but here only the one created in sheet metal is exported... I tried to convert the other elements to sheet metal but it only exports 1 :frowning:
… sorry I'm a complete beginner :roll_eyes:

Can you put us a screen print of what is the problem with the 5 sides? in order to better understand.

1 Like

Hello
You can take inspiration from the subject treated HERE otherwise see the attached macro if it suits you.

Kind regards
dxf-V2.swp (64 KB)

This is the kind of part and I need the dwg of each part for all configurations

Without a sheet metal body, unfortunately there is no miracle. Apart from the manual way for each part on the 20 configs...
No macro to my knowledge to choose several faces to export in dxf in several configs.

1 Like

… for one side it's fine with me as long as it does all the configurations (I have about forty) ... running the macro 4 times suits me very well :wink:

1 Like

Same principle, you make a configuration by body and convert them into sheet metal and then the macro will do the rest

1 Like

5 bodies so by launching 5 times the macro provided above by displaying that one body each time it must do it, it's to be launched in 5 different folders otherwise the files will crash as you go.
Kind regards

1 Like

@d.Roger no if he makes a configuration by body and converts them into sheet metal; It only needs to launch it once the macro as it launches into the room and converts the configurations.

1 Like

Hello @igor_simar ,

The Attachment macro claims to export the selected planar faces of a part one by one, in DXF or DWG format.
The exported documents are placed in a subfolder of the original part, with the same name.
The name of each document is formed by the sequence of the names of the original part, the body, the configuration, and the selected face.

Kind regards
ExportFaceToDxfDwg.swp (114 KB)

3 Likes

Hello @tous
In my opinion, after converting to sheet metal, it is possible to browse the folder of flattening of the same configuration
This guru did a great job Ex

1 Like

Just add this to ask for the export of the active configuration or all the configs

1 Like

THANK YOUIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
SUPER!!!
GREAT!!!
exactly what I wanted :wink:

@m.blt
I tried the code and it doesn't work


If I may, it seems to me that the file name has characters not allowed by windows, so the face can exist in one config and not in another
Kind regards