It's apparently the GetTitle function you're looking for. So in your macro you have to retrieve this GetTitle and rework the path of your file with the result obtained from the GetTitle.
GetTitle is an API function that allows you to retrieve, in text form, the name of the file opened in Solidworks, there you just wrote that your PDF file should be called GetTitle.PDF.
If you've never done a macro and/or programming, you'll either have to do a little research on how a programming language works before doing it, or you will have to post your full macro and explain how you want to change the way it works, hoping that someone will be willing to stick to it.
I admit I don't understand the remark "So far no worries I'm getting there" at the beginning of your question.
Yes, you have to get the name of your file first with the getTitle function.
I also admit that I don't really understand the "So far no worries I'm getting there"...
Try this:
'déclaration des variables
Dim swApp As Object
Dim Part As Object
Dim longstatus As Long
dim nomfichier as string
Sub enregistrement()
'initialisation des variables objet
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
'récupération du nom fichier part
Nomfichier = Part.GetTitle
'suppression de l'extension solidworks
Nomfichier = Strings.Left(Nomfichier, Len(Nomfichier) - 7)
'enregistrement du fichier en pdf
longstatus = Part.SaveAs3("C:\Users\dao\Desktop\MACRO_PDF-DWG\" & nomfichier & ".PDF", 0, 0)
end sub
Basically I understand how it works if you will, but indeed I have to ask myself more about the problem and the programming.
In fact it's relatively simple and I even think that this macro must already exist.
I just wish that once my drawing is finished, I click on a button, which generates a PDF and a DWG for me in a folder but with the name of the drawing open.
If I open a new drawing, I want this macro to generate other distinct and named files with this drawing.
I know well D.roger there was a bug I couldn't see the comments anymore we had to answer at the same time in fact. I'll test it and get back to you to tell you;) Thank you in any case:D
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Part.SheetPrevious
Part.SheetNext
boolstatus = Part.EditRebuild3()
' Redraw
Part.GraphicsRedraw2
' Zoom to Area
Part.ViewZoomTo2 0, 0, 0, 0.1, 0.1, 0.1
' Zoom to Area
Part.ViewZoomTo2 0, 0, 0, 0.1, 0.1, 0.1
' Zoom To Fit
Part.ViewZoomtofit2
' Redraw
Part.GraphicsRedraw2
' Save As
longstatus = Part.SaveAs3("C:\Users\dao\Desktop\MACRO_PDF-DWG\???.DWG", 0, 0)
' Save As
longstatus = Part.SaveAs3("C:\Users\dao\Desktop\MACRO_PDF-DWG\???", 0, 0)
End Sub
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
dim nomfichier as string
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Part.SheetPrevious
Part.SheetNext
boolstatus = Part.EditRebuild3()
' Redraw
Part.GraphicsRedraw2
' Zoom to Area
Part.ViewZoomTo2 0, 0, 0, 0.1, 0.1, 0.1
' Zoom to Area
Part.ViewZoomTo2 0, 0, 0, 0.1, 0.1, 0.1
' Zoom To Fit
Part.ViewZoomtofit2
' Redraw
Part.GraphicsRedraw2
'récupération du nom fichier part
Nomfichier = Part.GetTitle
'suppression de l'extension solidworks
Nomfichier = Strings.Left(Nomfichier, Len(Nomfichier) - 7)
' Save As
longstatus = Part.SaveAs3("C:\Users\dao\Desktop\MACRO_PDF-DWG\" & nomfichier & ".DWG", 0, 0)
' Save As
longstatus = Part.SaveAs3("C:\Users\dao\Desktop\MACRO_PDF-DWG\" & nomfichier & ".pdf", 0, 0)
End Sub
And I think your zooms will depend on the starting position, so I think it's better that you frame yourself before recording.
You will find HERE a discussion thread that dealt with the subject of learning programming on Solidworks, I advise you to read it to the end, you will find a whole bunch of interesting links.