Problem scaling dxf export

Hello

I take the liberty of asking for your help because I have a problem.

To save my bores in DXF quickly I use a macro (or even PJ) but since this morning when I use it the scale of my part is modified (for a circle ø100 on solidworks I find myself with a ø2000 on my DXF) on the other hand if I save under -> DXF no worries ...

Do you have any ideas about this problem? (I don't know anything about macro)

Thank you in advance.


saveas_dxf_1.swp

For those who want to see the macro without downloading it:

'**************************************************************************************************************************
'* Exemple de macro qui permet d'enregistrer les document au format DXF
'* Vous pouvez Changer l'extention pour enregistrer le document dans n'importe quelle format supporté par SW
'* Exemple réalisé par Axemble
'**************************************************************************************************************************
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swmodel As SldWorks.ModelDoc2
    Dim stPath As String
    Dim lgFichier As Long
    Dim blretval As Boolean
    Dim Errors As Long
    Dim Warnings As Long
    
    Set swApp = Application.SldWorks
    'on récupére le document actif
    Set swmodel = swApp.ActiveDoc
    
    If Not swmodel Is Nothing Then
       'on vérifie que le fichier est enregisté
        If swmodel.GetPathName = "" Then
            MsgBox "Veuillez enregistrer votre document avant de lancer la macro", vbInformation
            End
        Else
            'on récupére l'emplacement du fichier
            stPath = swmodel.GetPathName
            'on récupére le nombre de caractére jusqu'au . de l'extension
            lgFichier = InStrRev(stPath, ".", -1, vbTextCompare) - 1
            'on récupére le chemin sans l'extention
            If lgFichier > 0 Then
                  stPath = Left(stPath, lgFichier)
            End If
        End If
        
        'si le document est une pièce
        If swmodel.GetType = swDocPART Then
           'on créer le développé
            blretval = swmodel.ExportFlatPatternView(stPath & ".DXF", 0)
            'on créer le DXF
            blretval = swmodel.SaveAs3(stPath & ".DXF", 0, 0)
            
            'si le document est une mise en plan
        ElseIf swmodel.GetType = swDocDRAWING Then
            'on créer le DXF
            blretval = swmodel.SaveAs3(stPath & "_drw.DXF", 0, 0)
        End If
    
        'on sauvegarde le fichier
        blretval = swmodel.Save3(0, 0, 0)
   
    End If
End Sub

The problem of scale is from a room or a MEP?

Because nothing touches the scale in your macro. (simple save dxf for a room and the same thing for an MEP)

It seems that your problem comes from your layout scale different from that of the view and/or an export option. Is it possible to reach the MEP+part that is causing the problem?

The problem comes from one part (well several) but when I save them in DXF manually no problems on the other hand with the macro I have a change of scale.

EDIT: I just restarted the pc and solidworks and it works fine. (a PC or solidworks bug maybe??)

 

After testing the problem does not appear to me when the macro is launched from the room but only when it is launched from a drawing. Because the exported view is a ratio of the sheet scale. If in the dxf/DWG export option tool you enable output scale1:1, does that solve your problem? Otherwise the macro code will have to be modified.

3 Likes