Hello
I just tested "swModel.Save" on a simple SolidWorks macro, run on Solidworks with an open plane, and it updates the mapped variables well, like a simple Ctrl+S.
Here is the complete code (Script in the PDM task), thanks:
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim lErrors As Long
Dim lWarnings As Long
Dim pdmVault As Object
Dim strFullPath As String
Dim strFullPathWithoutExt As String
Dim strFolderPath As String
Dim strFileType As String
Dim intFileType As Integer
Dim i As Integer
Dim strFileName As String
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim Msg, Style, Title, Ctxt, Response
Sub Main()
'Initialize macro
strFullPath = "<Filepath>"
strFolderPath = "<Path>"
'Grabs filename only
i = InStrRev(strFullPath, "\")
strFileName = Right(strFullPath, Len(strFullPath) - i)
' Grabs FullPath without the extention to resolve the bug with UnlockFile and UPPERCASE instead of lowercase (Ex: SLDDRW / slddrw)
strFullPathWithoutExt = Left (strFullPath, Len(strFullPath) -6)
'Limit the macro to SolidWorks files
strFileType = LCase(Right(strFullPath, 6))
Select Case strFileType
"sldprt" box
intFileType = 1
Case "sldasm"
intFileType = 2
"Slddrw" box
intFileType = 3
Case Else
Msg = "File format error!" + Chr(13) + Chr(10) + "*.sldprt, *.sldasm, *.slddrw only!" + Chr(13) + Chr(10) + "File " + strFileName + " is ignored." ' Define message.
Style = vbMsgBoxSetForeground + vbCritical ' Define buttons.
Title = "STOP!" ' Define title.
Response = MsgBox(Msg, Style, Title)
Exit Sub
End Select
'Create vault object
Set pdmVault = CreateObject("ConisioLib.EdmVault")
pdmVault.Login "admin", "***********", "**********"
'Create folder object
Dim folder As Object 'IEdmFolder5 IEdmFolder11 EdmObject_Folder
Set folder = pdmVault.GetFolderFromPath(strFolderPath)
'Create file object
Dim file As Object
Set file = pdmVault.GetFileFromPath(strFullPathWithoutExt + strFileType, folder)
'Check out
If False = file. IsLocked Then
file. LockFile folder.ID, 0
Else
Msg = "Error: File " + strFileName + " already extracted by: " + file.LockedByUser.Name + " !" ' Define message.
Style = vbMsgBoxSetForeground + vbCritical ' Define buttons.
Title = "STOP!" ' Define title.
Response = MsgBox(Msg, Style, Title)
Exit Sub
End If
'Open save and close model
Set swApp = Application.SldWorks
swApp.Visible = False
Set swModel = swApp.OpenDoc(strFullPath, intFileType)
swModel.ViewZoomtofit2
swModel.ForceRebuild3 False 'False rebuil all and True rebuil only the top level
swModel.EditRebuild3
swModel.Save
'boolstatus = swModel.Save3(swSaveAsOptions_Silent, lErrors, lWarnings)
swApp.CloseDoc strFileName
'Check in
file. UnlockFile 0, "Automatic Update", 64
End Sub