ScriptUI palette returns .pathItems as String, not actual Array of items.
In basic terms I have a artboard covered in thousands rectangles and the script goes through each path/rectangle in the document, and add additional points to it (making it a hexagon), and then positions it on the artboard relative to the others. I had the script working fine as a dialog, but in switching it to a palette it has broken the code due to the complications with accessing PathItems.
I've been all over the internet trying to track this down, and currently this is what I think is happening:
- In order to access application information from a "palette" in ScriptUI (not a 'window' or 'dialog'), you need to use BridgeTalk
- Through bridgeTalk, results are being returned as a string.
- This results in the 'app.activeDocument.pathItems' called through BridgeTalk is being returned as "[PathItems]" (a string) and not an array of the actual paths.
My script is gigantic, but the relevant portion is below. Is there any way around this? Thanks!
//Outside of the palette code
function getPaths(){
return app.activeDocument.pathItems;
}
//Inside the palette code
//Get the total pathItems from the file
var bt2 = new BridgeTalk();
bt2.target = "illustrator";
bt2.body = getPaths+'getPaths();';
bt2.onResult = function(result){
for (i=0; i < totalPills; i++ ) {
myPaths = result.body;
}
}
bt2.send();