I have made some progress with the use of Copilot to this point.
1) on shortcut key file opens to pick nod file.
2) Nodeditor opens automatically on selection of nod file.
3) File fails to load with undifined error.
Problem with path I think.
Here's the JS code.
function openNodeFile() {
try {
// Open the file selection dialog
var 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);
// Open the Nodeditor dialog with the correct path
moi.ui.createDialog('moi://appdata/nodeeditor/index.html?scheme=Light', 'resizeable,defaultWidth:680,defaultHeight:420', moi.ui.mainWindow);
// Attempt to load the selected .nod file into the Nodeditor
// Placeholder for actual logic to load the file
// If `loadNodeFile` is not the correct method, replace this with the correct one
if (typeof moi.ui.commandUI.loadNodeFile === 'function') {
moi.ui.commandUI.loadNodeFile(filePath); // Replace with the correct method if necessary
moi.ui.alert('File loaded successfully.');
} else {
moi.ui.alert('Error: loadNodeFile method not found in moi.ui.commandUI.');
}
} catch (error) {
moi.ui.alert('Error: ' + error.message);
}
}
// Run the openNodeFile function
openNodeFile();
|