#encoding: utf-8 import dia def test(data, flags): classes = [] layer = dia.active_display().diagram.data.layers[0] for obj in layer.objects: if obj.type.name == "UML - Class": print "\nobject", obj CP_ATTR_OFS = 8 # not including the mainpoint i = 0 connections = [] for cpt in obj.connections : # connection points for co in cpt.connected : # connected objects in this point connections.append ((i, co)) i += 1 attrs = obj.properties['attributes'].value for con in connections : n = con[0] - CP_ATTR_OFS attr = attrs[n/2] if (n % 2) == 0 : print n, "\t %s left: connected to %s" % (attr[0], con[1]) else : print n, "\t %s right: connected to %s" % (attr[0], con[1]) #for attr in obj.properties['attributes'].value: # attr is a tuple, len(attr) == 9 # left_connection: attr[7] -> ConnectionPoint # right_connection: attr[8] -> ConnectionPoint # if attr[7].connected: # print "\t %s left: connected to %s" % (attr[0], # attr[7].connected) # if attr[8].connected: # print "\t %s right: connected to %s" % (attr[0], # attr[8].connected) classes.append(obj) #dia.register_callback("Test", "/Debug/AttConns", test) dia.register_action ("TestAttConns", "Attribute connections", "/DisplayMenu/Debug/DebugExtensionStart", test)