Save As
Posted: Tue Jan 08, 2008 10:53 pm
Would it be possible to reimplement the 'save as' for maxwell scenes back into Solidworks? - its a lot quicker to use when saving out lots of different mxs files.
The official Maxwell Render public forum. A place to share your latest projects and be inspired by others, or get help and feedback from the Maxwell community
https://forum.maxwellrender.com/
Dim swApp As Object
Dim prevName As String
Sub Maxwell_SaveAs()
On Error GoTo Cancel:
Dim maxwell As Maxwell_Script.ScriptObject
Set maxwell = New Maxwell_Script.ScriptObject
If maxwell Is Nothing Then
MsgBox "Unable to create Maxwell ScriptObject. Please make sure that the Maxwell Script library has been installed."
Exit Sub
End If
If Not maxwell.IsConnected Then
MsgBox "Unable to connect to the current Maxwell Scene. It may help to re-start SolidWorks."
Exit Sub
End If
If prevName = vbNullString Then
Set swApp = Application.SldWorks
If swApp Is Nothing Then
MsgBox "Unable to connect to SolidWorks."
Exit Sub
End If
Dim swModel As ModelDoc2
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "There is no active document."
Exit Sub
End If
prevName = swModel.GetPathName
prevName = Replace(prevName, "sldprt", "mxs")
prevName = Replace(prevName, "SLDPRT", "mxs")
prevName = Replace(prevName, "sldasm", "mxs")
prevName = Replace(prevName, "SLDASM", "mxs")
End If
Dim dlg As Object
Set dlg = CreateObject("MSComDlg.CommonDialog")
If dlg Is Nothing Then
MsgBox "The script was not able to create the save-file dialog."
WScript.Quit
GoTo Cancel
End If
dlg.MaxFileSize = 260
dlg.FileName = prevName
dlg.DialogTitle = "Save MXS As"
dlg.Filter = "MXS Files (*.mxs)|*.mxs"
dlg.CancelError = True
dlg.ShowSave
Dim fName As String
fName = dlg.FileName
If fName <> vbNullString Then
maxwell.Output.ScenePath = fName
maxwell.Rendering.RenderToMxs
MsgBox "MXS saved as: " & fName
prevName = fName
End If
Cancel:
Set dlg = Nothing
End Sub