You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing an auto-layouter that transforms the JSON export format into a graph structure. The structure is then run through a layouter (GraphVis, etc.) to generate position coordinates for each node in the patch. The idea would be to then use the positions to issue move commands to reposition each of the nodes.
So far creating the graph structure has been straight forward. But I can't figure out out to get a node by id to issue the move event.
Here's the current code to get the idea:
function autoLayout() {
var nodes = [];
var edges = [];
function getProject() {
// Use export json parse format to generate
// graph structure from events
return project();
}
function createGraph() {
let project = getProject();
let pgraph = project.commands
console.log(pgraph)
let o = 0;
let olen = pgraph.length
for ( o; o < olen; o++ ) {
if ( pgraph[o].event === 'patch/add-node' && pgraph[o].nodeType !== 'util/nodelist' ) {
let node = new Object();
node.id = pgraph[o].nodeId;
node.title = pgraph[o].nodeTitle;
nodes.push(node);
}
if ( pgraph[o].event === 'node/add-outlet' ) {
let edge = new Object();
edge.source = pgraph[o].nodeId;
for ( p = o+1; p < olen; p++ ) {
if ( pgraph[p].event === 'node/add-outlet' ) {
edge.target = pgraph[p].nodeId;
break;
}
}
if ( H.Obj.has_own(edge, 'target') ) {
edges.push(edge)
}
}
}
console.log(nodes)
console.log(edges)
}
function runLayouter() {
// THIS IS THE MISSING PIECE
**let n = Rpd.getNodeById(id);**
n.move(pos_x, pos_y)
}
function createMoves() {
}
createGraph()
}
The text was updated successfully, but these errors were encountered:
I'm writing an auto-layouter that transforms the JSON export format into a graph structure. The structure is then run through a layouter (GraphVis, etc.) to generate position coordinates for each node in the patch. The idea would be to then use the positions to issue move commands to reposition each of the nodes.
So far creating the graph structure has been straight forward. But I can't figure out out to get a node by id to issue the move event.
Here's the current code to get the idea:
The text was updated successfully, but these errors were encountered: