Customization > Automation Interface > Functions > For User Interface > Functions for diagrams > LockDiagram function (automation interface)
LockDiagram function (automation interface)
Syntax:
LockDiagram ("<id>", TRUE¦FALSE)
Where:
<id> is a string that specifies the id of the diagram that is to be locked or unlocked.
TRUE attempts to lock (make editable) a diagram.
FALSE attempts to unlock (make read-only) a diagram.
For all diagram types except Text Diagrams:
LockDiagram with TRUE takes an exclusive lock on a diagram so that you can change it (unless the diagram is locked to another user)
LockDiagram with FALSE unlocks a diagram that is locked by you in the model so that other users can change it.
LockDiagram uses the Diagram Object's Id property. This function returns a Boolean value to indicate success or failure.
For Text Diagrams
LockDiagram with TRUE makes the diagram editable without taking a lock. When a change is made to the diagram, the diagram attempts to take an exclusive lock for you.
LockDiagram with FALSE:
If the diagram has been modified, LockDiagram with FALSE will not do anything. The lock is released when the diagram changes are saved or canceled.
If the diagram has not been changed, the diagram is made read-only.
Use the IsDiagramLocked function to determine whether a diagram is locked by you.
Examples
In this example, the script locks Class Diagram1 through its Id, that is, makes the diagram editable:
Set objDiagrams = ActiveProject.Item("Diagrams")
Set objDiagram = objDiagrams.Item("Class Diagram", "Class Diagram1")
strDiagram = objDiagram.Property("Id")
Call Studio.LockDiagram (strDiagram, TRUE)
In this example, the script unlocks Class Diagram1 through its Id, that is, makes the diagram read-only:
Set objDiagrams = ActiveProject.Item("Diagrams")
Set objDiagram = objDiagrams.Item("Class Diagram", "Class Diagram1")
strDiagram = objDiagram.Property("Id")
Call Studio.LockDiagram (strDiagram, FALSE)
Was this helpful?