Asking for an addon (Could this addon be created?)
All  1-17  18-19

Previous
Next
 From:  Michael Gibson
11600.18 In reply to 11600.15 
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();

EDITED: 26 Nov 2024 by MICHAEL GIBSON

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Barry-H
11600.19 In reply to 11600.18 
Thanks Michael,
works fine now.
Cheers
Barry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages: All  1-17  18-19