Question & Answer
Question
How do you set the type and multiplicity of tags using the Microsoft Visual Basic API in IBM Rational Rhapsody?
Cause
You would like to use Visual Basic [VB] Application Programming Interfaces [API] code to automate the manual task to be performed with in Rational Rhapsody.
Answer
You can use the API method 'setTypeDeclaration(String type)' and the API attribute 'multiplicity' to set the type and multiplicity of tags using VB API.
Find below a sample code for your reference:
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
---|
Sub updateTagValue()
Dim Sel, Lit As RPModelElement
Dim Tag As RPTag
Set Sel = getSelectedElement()
Set Tag = Sel
If Tag.value = "" Then
Call Tag.setTypeDeclaration("type_1")
Tag.multiplicity = "1..*"
For Each elem In Tag.typeOf.enumerationLiterals.Items
Debug.Print elem.name
Set Lit = Tag.addNewAggr("LiteralSpecification", "")
Lit.value = elem.name
Next elem
End If
End Sub
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21433977