Macro save in *.sat

Hello, I'm looking for a macro that would allow me to add a save in sat button.

Does anyone have a tutorial, or directly this little macro in these drawers?

Thank you in advance, very cordially,

Besnier JB

Hello

There's a macro here:

https://forum.solidworks.com/message/215237#215237

See also:

https://forum.solidworks.com/thread/74872

https://forum.solidworks.com/thread/32671

 

And to add a button, see my tutorial:

http://www.lynkoa.com/tutos/3d/ajouter-un-bouton-pour-macro-dans-solidworks

 

And why can this question be silly?

don't take a macro like the one posted on this thread since after testing it works well

http://www.lynkoa.com/forum/cao/creer-une-macro-pour-exporter-en-xt-sur-solidworks-2010

and simply turn the destination into .sat

maybe I'm saying something stupid ;-((

See with the macro specialists

@+ ;-))

2 Likes

Indeed GT22, we can try the following macro:

Sub Sauvegarde_X_T()

 

   
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Locatie As String
Dim Locatie_aangepast As String
Dim OpenDoc As Object
Dim Extensie_nieuw As String
Dim Extensie_oud As String
Dim retval As String
Dim Naam As String
Dim Naam_aangepast As String

 

Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set OpenDoc = swApp.ActiveDoc()

Extensie_oud = ". SLDASM"
Extensie_nieuw = ". SAT"
Locatie = OpenDoc.GetPathName
Locatie_aangepast = Left(Locatie, Len(Locatie) - 7)
retval = Dir$(Locatie_aangepast & Extensie_oud)
Naam = Dir$(Locatie)
Naam_aangepast = Left(Naam, Len(Naam) - 7)
Titel = OpenDoc.GetTitle
Titel = Left(Titel, (Len(Titel)))


   ' If retval = Naam Then
        'nRetval = swApp.SendMsgToUser2(Naam_aangepast & " DXF created !!! ", swMbWarning, swMbOk)
   ' End If
    
    
Set Part = swApp.ActiveDoc
longstatus = Part.SaveAs3(Naam_aangepast & Extensie_nieuw, 0, 0)

End Sub

@PL, obviously changing: "DXF creates!!! " by ". SAT created !!! "

The following part of the code is inactive:

' If retval = Naam Then
        'nRetval = swApp.SendMsgToUser2(Naam_aangepast & " DXF created !!! ", swMbWarning, swMbOk)
    ' End If

I think the developer wanted to do an error detection in case the file already exists.

However, SW already takes this into account.

1 Like

And damn, ok I didn't say anything ;)!