Navigating the canvas root element

I was trying to use the answer given here to produce an SVG of the subprocess element. However, the canvas#setRootElement method throws the error “Element already exists”. I tried removing the element from the element registry, but then the saveSVG() method generates an empty SVG. I’m pretty sure this is just a misunderstanding on my part, but I can’t figure it out.
I reproduced the error here: Sandbox demo.

hi @kirstenhh ,

you can fix this replacing
.filter((el) => is(el, “bpmn:SubProcess”) && el.collapsed);
for
.filter((el) => el.type === “bpmn:SubProcess” && el.hasOwnProperty(“layer”));

the collapsed sub process created two element, one for represent in designer and other for design

This worked, thank you! (I’ll update the CodeSandbox so there’s a working example, for anyone who comes across this later)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.