Best way to makeSvg() for a group part so all its children render too


I’m using the following code to download an SVG file of the current digram.selection part. It works just fine for all part types, except for groups. When the selected part is a group, (which in my case is a simple rectangle containing parts), all I get in the SVG is the rectangle of the group, not the child parts of the group. My group can also contain other groups.

So, is there a method I can call on my outermost group that will return a flat list of all the parts in that group, recursively? So I can pass that flat array to makeSvg(). Or do I have to do this myself?

function downloadSVGForSelection(scaleSize) {
    if (myDiagram.selection.toArray().length > 0) {
        myPartsList = new go.List();
        myDiagram.selection.each(function (part) {
            if (part instanceof go.Node) {
        var svg = myDiagram.makeSvg({ scale: scaleSize, background: "white", parts: myPartsList })
        var svgstr = new XMLSerializer().serializeToString(svg);
        var blob = new Blob([svgstr], { type: "image/svg+xml" });
    } else {
        alert("Please select a node to print")

function downloadSVGCallback(blob) {
    let dt = new Date().toISOString().slice(0, 16).replace(":", "-")
    var url = window.URL.createObjectURL(blob);
    let procedure = getProcedureID(false)
    var filename = "procedure_" + procedure + "_time_" + dt + ".svg";

    var a = document.createElement("a"); = "display: none";
    a.href = url; = filename;

    // IE 11
    if (window.navigator.msSaveBlob !== undefined) {
        window.navigator.msSaveBlob(blob, filename);

    requestAnimationFrame(function () {;

Call to get a collection of all of the (possibly indirect) members of a Group.