script to move a group around within a matrix
Is there a scripting method that allows us to move a group around within a matrix to rearrange the positioning of my groups/items?
There is a way to use the method of nodeRange.moveToNext(false) or nodeRange.moveToPrevious(false) but it only works at the item level. Is there any documentation for these method? The code completion does not show, and it is not in the online reference either.
In the quantrix matrix screen, it is clearly easy to move a group by selecting a group and pressing the control+up or control+down. I am looking to do something similar but via scripting.
Any help would be appreciated.
Thanks
D
Hello – Thank you for your question. While moving nodes is not supported, our engineers have provided a possible workaround.
See below:
def group = |MyMatrix::MyGroup|.wrapped
def cat = group.category
cat.moveNode(group, group.childIndex + 1)
(or “- 1” to move up/left instead of down/right)
* The reason it’s not documented is because it’s not supported
This should work long as you’re not trying to move it outside its parent group:
def group = |My Matrix::My Group|.wrapped
group.parent.moveNode(group, group.childIndex + 1)
This works nicely! Much appreciated!
Thanks so much! This works at the first level groups(where the group’s parent is a category), but does not work for nested groups (secondary level grouping where the group’s parent is also a group) that needs to be moved. Is this possible?