Question & Answer
Question
How do I display Flow Property directions using a VBA macro?
Answer
You may use the following VB macro sample to display flow property directions:
Sub flowprDirection()
Dim rpy As RPProject
Dim pack As RPPackage
Dim cls As RPClass
Dim pts As RPModelElement
Dim dirs As RPModelElement
Set rpy = getProject
For Each pack In rpy.packages
For Each cls In pack.classes
For Each pts In cls.ports
Debug.Print "Block Name : " & cls.name & Space(5) & " Flowport name : " & pts.name
For Each att In pts.ObjectAsObjectType.attributes
For Each dirs In att.allTags.Items
Debug.Print “Flowproperty Name: “& att.name & Space(5) & “Direction : “& dirs.defaultValue
Next dirs
Next att
Debug.Print ""
Next pts
Next cls
Next pack
Set rpy = Nothing
End Sub
Additional Information:
----------------------------------
Equivalent Java API code to display flow property directions:
import java.util.Iterator;
import com.telelogic.rhapsody.core.IRPApplication;
import com.telelogic.rhapsody.core.IRPClass;
import com.telelogic.rhapsody.core.IRPPackage;
import com.telelogic.rhapsody.core.IRPProject;
import com.telelogic.rhapsody.core.IRPSysMLPort;
import com.telelogic.rhapsody.core.IRPAttribute;
import com.telelogic.rhapsody.core.IRPTag;
import com.telelogic.rhapsody.core.RhapsodyAppServer;
public class test {
public static void main (String[] args) {
IRPApplication myApp = RhapsodyAppServer.getActiveRhapsodyApplication();
IRPProject myPro = myApp.activeProject();
Iterator myIter1 = myPro.getPackages().toList().iterator();
while (myIter1.hasNext())
{
IRPPackage myPkg = (IRPPackage) myIter1.next();
Iterator myIter2 = myPkg.getClasses().toList().iterator();
while (myIter2.hasNext())
{
IRPClass myCls = (IRPClass) myIter2.next();
Iterator myIter3 = myCls.getPorts().toList().iterator();
while (myIter3.hasNext())
{
IRPSysMLPort myPort = (IRPSysMLPort) myIter3.next();
System.out.println("Block Name : " + myCls.getName());
System.out.println("Flowport Name : " + myPort.getName());
Iterator myIter4 = myPort.getObjectAsObjectType().getAttributes().toList().iterator();
while (myIter4.hasNext())
{
IRPAttribute myAtt = (IRPAttribute) myIter4.next();
Iterator myIter5 = myAtt.getAllTags().toList().iterator();
while (myIter5.hasNext())
{
IRPTag myDir = (IRPTag) myIter5.next();
System.out.println("Flowproperty Name: " + myAtt.getName() + "\t" + "Direction : " + myDir.getDefaultValue());
}
}
}
}
}
}
}
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. |
---|
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21402593