Rhapsody Diagrams in EMF format

When producing a document from Rhapsody the diagrams will be generated in JPG format. For large/dense diagrams this is sub-optimal as the details of the diagrams become difficult to distinguish.

The solution for this is to request the diagrams in EMF format which is a combination of vector and bitmap graphics. Rhapsody’s Reportable REST API is set to generate JPG images by default but it can be made to return EMF instead.

When you make a request to get a diagram, such as http://localhost:27463/Rational/Rhapsody/?fields=Projects/Project/(name|PredefinedQueries/AllSequenceDiagrams/SequenceDiagram/(descriptionXHTML|name|Pictures/Picture/(path)))
Rhapsody returns the following:


The extracted image type is determine according to the XXX  string (Picture__JPG__1__1) in the URL.  The Rhapsody ‘s REST API actually  knows to extract an EMF image, but currently it is  “hard coded” in rhapsody to extract “JPG”.  If you replace the picture path URL “JPG” string with “EMF” you will get from Rhapsody an EMF image.

The replacement can be easily made in the RPE image element for the diagram using the following Java Script. You can use a more strict pattern with JavaScript

path.replace( "__JPG__", "__EMF__") : path;

An example template that extracts Sequence Diagrams as EMFs is available in the RPE Community Template Library.  The template was tested with the Home Alarm example example and Rhapsody 8.0.6 and produced the following document: testRHP_EmfImages If you open the document you will observe that you are able to edit the diagrams and access each detail independently ( you can notice that the line color was changed to green).


Author: Dragos Cojocari

Architect for Rational Publishing Engine

2 thoughts on “Rhapsody Diagrams in EMF format”

  1. In order for the Java Script to work and grab the EMF image from Rhapsody, the “emfImages” variable used in the template must be set to “true” in the document specification.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s