Hi,
I seem to have an error when trying to render Block Diagrams via script. Here is the error message:

I tried to check my code and there seems to be no mistakes. The error happens when trying to call renderDiagram() function from diagram.js library.
What could possibly be the problem?
The following is the script:
function main(){
//ASK FROM USER, WHERE TO PLACE FILES (Path of Directory or Folder)
var outputPath = openDirectory("Please select directory");
if (outputPath) {
console.log("Output Path: " + outputPath);
//FIND ALL PJDIAGRAMS INSIDE MEDINI PROJECT
var allPJDiagrams = finder.findByType(Metamodel.projectmodel.PJDiagram, true).asList();
//RENDER IMAGES FOR EACH BLOCK DIAGRAM
for(var i = 0; i< allPJDiagrams .size(); i++){
var diag = allPJDiagrams .get(i);
if(allPJDiagrams .get(i).modelID == "SysML"){
console.log(allPJDiagrams .get(i).name);
console.log(" " + allPJDiagrams .get(i).mediniIdentifier);
renderDiagram(diag, outputPath, "PNG");
}
}
console.log("Finished Rendering");
selectOption("Export Finished", "Export has Finished. File is save in " + outputPath, ["OK"]);
} else {
selectOption("No Directory Selected", "You selected no directory. Script will abort", ["OK"]);
}
}