Subgraph Expand Collapse

cnvs = document.windows[0].selection.canvas
cnvs.graphics.forEach(function(graphic){
	if(graphic instanceof Subgraph){graphic.collapsed = false}
})

I would like to know how to modify this script to apply it only to the selection.
The reason I want to know that is because I want to operate on IOS.

1 Like

This script works on iOS.
But it expands ALL subgraphs in a canvas.
I’d like to do that for a selected one.

please help me someone knows .!

Instead of going from the window’s selection to the canvas and looping through all of the graphics on that canvas, you can take your list of graphics directly from the selection:

document.windows[0].selection.graphics.forEach(function(graphic){
	if(graphic instanceof Subgraph){graphic.collapsed = false}
})

If you’re implementing this as a plug-in action which is passed a selection as its first parameter, you can reference that selection parameter directly (e.g. writing selection.graphics) rather than going through the document to its first window (writing document.windows[0].selection.graphics).

Hope this helps!

2 Likes

Hi, kcase
Thanks a lot! and it works!!!

I hope iOS app could touch Subgraphs near future !!
Then I can remove all my other mindmapping apps and make concentration to OG. ;))

1 Like