Dear All,
I'm having a DriveWorks project, where we need to save a screendump.png file of an assembly to a DrwiveWorks specified folder.
I manged to to get the below to work copying and pasting from different sources.
This seems to work, but I'm having trouble to get the model view correct.
I tried recording a new macro and do a trimetric zoom to fit, and inserted it as seen below. This however don't work.
Is there a friendly code expert who can help me explaining the three lines in bold below? I searcehd API help without luck.
Thx,
Flemming
Sub Main()
' Get SolidWorks
Dim swApp As SldWorks.SldWorks
Set swApp = Application.SldWorks
' Get the currently open document
Dim model As ModelDoc2
Set model = swApp.IActiveDoc2
Set Part = swApp.ActiveDoc
Part.ViewZoomtofit2
Part.ShowNamedView2 "*Trimetric", 1
' Get the "general", i.e. non-configuration specific, custom property manager
Dim cpm As CustomPropertyManager
Set cpm = model.Extension.CustomPropertyManager("")
' Get the custom property called SaveLocation
Dim saveLocation As String
saveLocation = cpm.Get("SaveLocation")
' Save the file to the new location
' and change the extension
Dim Extension As String
Extension = Mid(saveLocation, InStrRev(saveLocation, "."))
saveLocation = Replace(saveLocation, Extension, ".png")
Extension = ".png"
Dim version As swSaveAsVersion_e
Dim options As swSaveAsOptions_e
Dim errors As Long
Dim warnings As Long
Dim result As Boolean
result = model.Extension.SaveAs(saveLocation, version, options, Nothing, errors, warnings)
End Sub