How to set the event id of triggered operation from a user defined value?
You can set the event id of triggered operation from a user defined value by running a VB script. To do this, follow the steps below:
- Create a Rhapsody model
- Create a class named "ClassA" under "Default" Package
- Create triggered operations under class "ClassA"
- Go to Tools -> VBA -> Visual basic Editor
- Type the code found below in a new Module of the VB editor and save it.
- Run the macro named a by selecting Tools -> VBA->Macro -> generate_id
Sub generate_id()Dim itemVal As IntegeritemVal = 1 ' Initial value for the triggered operation
For Each element In getProject.packages
For Each subelement In element.classes
For Each item In subelement.operations
If item.metaClass = "Operation" Then
item.setPropertyValue "CG.Event.Id", itemVal
itemVal = itemVal + 1 ' To sequentially increment the value of triggered operation
The macro would now set the triggered event ids to start with 1 and increment it by 1 for every triggered operation.