-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
When adding links the function addLink creates IDs based on source and destination.
When there are multiple parallel links between two nodes DrawIO throws an error as it cannot handle duplicates.
Solved by creating uniqe IDs.
One solution could be to generate a random string and attach it to the ID.
import random
import string
def addLink(self,sourceNodeID,destinationNodeID):
try:
for mxCell in self.root:
print(mxCell.attrib['id'])
print(type(mxCell.attrib['id']))
print(sourceNodeID)
print(type(sourceNodeID))
if mxCell.attrib['id'] == sourceNodeID:
print('Element found' + {mxCell.attrib['id']})
break
return
except Exception as e:
print(e)
random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=4))
mxCell = ET.SubElement(self.root,
'mxCell',
id=sourceNodeID+destinationNodeID+random_string,
style="endFill=0;endArrow=none;",
parent="1",
source=sourceNodeID,
target=destinationNodeID,
edge="1")
mxGeometry = ET.SubElement(mxCell, 'mxGeometry')
mxGeometry.set('as','geometry')
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels