file How to get class interfaces

4 weeks 2 days ago - 4 weeks 2 days ago #5182 by ValeV
I have a Class Diagram and am using code example ( ). First I want to access Class' Interfaces. Then, I want to access Class' Interfaces' description.

How do I access interface nodes? node.getNodes() on a Class element returns empty list even though in Model, class contains interfaces.

Do I have to drag and drop Interfaces onto the Diagram somewhere?

Any help is much appreciated.

EDIT: to add the code:
def dumpNode(node, indent):
	if node != None:
		bounds = node.getBounds()
		print indent, '<node name="' +  node.getElement().getName() + '" class="' + node.getElement().getMClass().getName() + '">'
		if node.getElement().getMClass().getName() == "Class":
			print "Description:", node.getElement().getNoteContent("ModelerModule", "description")
			print "" #here I would like to get children nodes (Interfaces)
		for n in node.getNodes():
			dumpNode(n, indent+"  ")
		#for l in node.getFromLinks():
		#	dumpToLink(l, indent+"  ")
		#for l in node.getToLinks():
		#	dumpFromLink(l, indent+"  ")
		print indent, '</node>'

EDIT 2: added a picture. Basically, I want to access interfaces of class "em_brake.c".

Please Log in or Create an account to join the conversation.

4 weeks 7 hours ago #5184 by pan
Actually, you cannot get the Interfaces because they are not shown in the diagram. The script example is aimed to display elements visible in a diagram. If you want to display the interfaces, you have to change the representation mode (in the Symbol view) of the Component EMBrake to Simple so the interfaces will be visible.

If you want to list inner elements even if they are not displayed in the diagram you will need to adapt the script.
For example you can do this:
elt = node.getElement()
if isinstance(elt, Class):		
	for oelt in elt.getOwnedElement():
	print '<ModelTree name="' + oelt.getName() + '"></ModelTree>'

Hope this helps.

Please Log in or Create an account to join the conversation.

Moderators: tmaebr
Time to create page: 0.100 seconds
^ Back to Top