Show messages: All
1-16
17-19
From: Michael Gibson
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();
From: Michael Gibson
Hi Barry, so the part about telling the node editor which file to load using a file= parameter in the URL is a little buggy in the node editor code.
To fix it, open the node editor file init.js and find this on line number 44:
code:
var data = '', loadFilePath = NeParameters.file.replace(/%5C/g,"\\");
change it to this instead:
code:
var data = '', loadFilePath = decodeURIComponent(NeParameters.file);
Then the code to use it should go 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=' + encodeURIComponent(filePath);
// Open the Nodeditor dialog with the correct path
moi.ui.createDialog(url, 'resizeable,defaultWidth:680,defaultHeight:420', moi.ui.mainWindow);
} catch (error) {
moi.ui.alert('Error: ' + error.message);
}
}
// Run the openNodeFile function
openNodeFile();
From: Barry-H
Thanks Michael,
works fine now.
Cheers
Barry
Show messages: All
1-16
17-19