Hi Barry, so although there does not seem to be a loadNodeFile() function, you can give the node editor a parameter named 'file' in the URL's search string to tell it which file to load when it starts.
Like this:
code:
function openNodeFile() {
try {
// Open the file selection dialog
filePath = moi.filesystem.getOpenFileName('Open', 'MoI Nodeeditor files (*.nod)|*.nod');
if (!filePath) {
moi.ui.alert('No file selected.');
return; // Exit if no file is selected
}
// Alert the selected file path
moi.ui.alert('File selected: ' + filePath);
// Put parameter file=path.nod in the URL's search string to have it load the file.
var url = 'moi://appdata/nodeeditor/index.html?scheme=Light&file=' + filePath;
// Open the Nodeditor dialog with the correct path
moi.ui.createDialog(encodeURI(url), 'resizeable,defaultWidth:680,defaultHeight:420', moi.ui.mainWindow);
} catch (error) {
moi.ui.alert('Error: ' + error.message);
}
}
// Run the openNodeFile function
openNodeFile();
|