Propagating changes to the database
In this post , we learned how to create an object in the database. However, this process has some limitations.
Now, we will see how to save an open object.
First, we are not actually saving anything; in 3DEXPERIENCE jargon, we are propagating the changes. To do so, we must use the PLMPropagateService
. Once the service is retrieved, the process is quite simple: PLMPropagate
will do the job.
Note: PLMPropagate only propagates changes of the “Active Editor.”
If the propagate action is not carried out correctly for any reason, the reason can be retrieved using the method getLastError
. This method provides the error number and description.
Option Explicit
Sub CatMain()
Call PropagateChanges
End Sub
' Save the changes to the database of the current editor only
Public Function PropagateChanges()
On Error GoTo ErrorHandler
Dim PropagateService As PLMPropagateService
Set PropagateService = CATIA.GetSessionService("PLMPropagateService")
Call PropagateService.PLMPropagate
Dim ErrorCode As Long
Dim ErrorMessage As String
Call PropagateService.getLastError(ErrorMessage, ErrorCode)
If ErrorCode <> 0 Then
Call MsgBox(ErrorMessage, vbCritical, "Propagation Error.")
End If
Exit Function
ErrorHandler:
Call MsgBox("Error while propagating changes.", vbCritical, "Propagation Error")
End Function