Friday, October 31, 2008

Using the Gaphor UML model

The Gaphor UML modeling tool is is written in Python and has has an easily accessible UML model API. This API can be used by other applications as well. The source code for the current Gaphor release can be found here.

Here is an example of how we can initialize an ElementFactory instance.

from gaphor.UML.elementfactory import ElementFactory
from gaphor.UML import Class

if __name__=='__main__':
print 'Factory initialized with %s elements.'%(factory_obj.size())

We can then use this ElementFactory instance to create new UML elements as illustrated below.

print 'Class object created with ID: %s'%(

In the future, I'll go into more detail about the ElementFactory class in future posts because it is a useful tool for Python applications.