I would like to make a macro that saves a photo of each view of the open assembly but when I save the macro the change of view does not save what is the line to type to achieve this?
Hello
Here is the list of views:
Dim swApp As Object
Dim Part As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
' Part.ShowNamedView2 "Normal à", 0 'Normal à un plan ou une face sélectionné(e)
Part.ShowNamedView2 "Face", 1
' Part.ShowNamedView2 "Dos", 2
' Part.ShowNamedView2 "Gauche", 3
' Part.ShowNamedView2 "Droite", 4
' Part.ShowNamedView2 "Dessus", 5
' Part.ShowNamedView2 "Dessous", 6
' Part.ShowNamedView2 "Isométrique", 7
' Part.ShowNamedView2 "Trimétrique", 8
' Part.ShowNamedView2 "Dimétrique", 9
' Part.ShowNamedView2 "Vue perso 1", -1
' Part.ShowNamedView2 "Vue perso 2", -1
Part.ViewZoomtofit2 'Ajuste le cadrage de la pièce ou l'assemblage à la vue
End Sub
For standard views, the name of the view in quotes is purely indicative, you can replace it with "" or "blabla" it still works, only the number defines the view to be shown.
For custom views, on the other hand, the number is always -1 and only the name in quotation marks (corresponding of course to the name given to the view when it was created) defines the view to be shown.
Hello, Here is the macro I made, why doesn't it work?
' ******************************************************************************
' C:\Users\domon\AppData\Local\Temp\swx19096\Macro1.swb - macro recorded on 08/11/22 by domon
' ******************************************************************************
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
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
' Part.ShowNamedView2 "Face", 1
' Part.ViewZoomtofit2
' Save As
longstatus = Part.SaveAs3("E:\Desktop\Capture\face.JPG View", 0, 2)
End Sub
macro0004.swp
Hello
Because you left the ShowNamedView2 and ViewZoomtoFit2 lines in the comments... The apostrophes at the beginning of lines must be removed.
PS: I've started writing an advanced macro to handle mass saving of frame images, for multiple docs, multiple views, parameterized views, and more. Preview: