Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Alexander.Golyshkin on March 23, 2024, 12:33:17 am
-
Hi,
1. How possible to add a diagram notes to diagram using an scripting API having an extracted pointer to Diagram Class?
2. How possible to change a text in Note element in existed Note using scripting API having an extracted pointer to diagram element by getRepo().GetElementByID( diagramObject.ElementID )
-
Basically like adding anything to a diagram. You create a note element with the desired content and create a diagramobjects element containing the diagram id and the position.
Changing notes is also simple by retrieving it from the elements, make changes and update it.
q.
-
Since, there were no help from Sparx team, I have found the solution for adding diagram info note & diagram not with GUID and paperclip style to the diagram canvas:
def _addDiagramNotes( self, aDiagramNode: CDispatch ):
pck = self._engine.getRepo().getPackageByID( aDiagramNode.packageID )
text = pck.elements.addNew( "", "Text" )
text.Subtype = 18
text.Update()
# coord. on diagram
obj = aDiagramNode.diagramObjects.addNew( "l=10;r=110;t=-20;b=-80", "" )
obj.elementID = text.elementId
obj.Update()
self._engine.getRepo().reloadDiagram( aDiagramNode.diagramID )
LOGGER.info( "Added TextInfo to Diagram" )
def _addDiagramGUIDNote( self, aDiagramNode: CDispatch ):
pck = self._engine.getRepo().getPackageByID( aDiagramNode.packageID )
note = pck.elements.addNew( "", "Note" )
note.Notes = aDiagramNode.DiagramGUID
note.StyleEx = "NS=5"
note.Update()
# coord. on diagram
obj = aDiagramNode.diagramObjects.addNew( "l=10;r=250;t=-100;b=-155;DUID=A15050D3", "" )
obj.elementID = note.elementId
obj.Update()
self._engine.getRepo().reloadDiagram( aDiagramNode.diagramID )
LOGGER.info( "Added Notes GUID to Diagram" )