I'm trying to use the below script to combat legacy compound paths that result from Photoshop. I tried placing a try catch around the expandStyle menu command, to combat errors, but in testing with and without it, it appears that I'm unable to use expand style, unless I select the plugin items myself. I tried adding $.sleep to see if it just needed time to catch up, but to no avail. The multiple redraws helped in other situations that scripts ran too fast but don't seem to be doing much in this case. Is there a different way I should be selecting these items via scripting to ensure I can expand them?
Below is what the group looks like when I select via script:
Below is what it looks like when I select it manually, note the target is highlighted:
//Expand Legacy Compound Shapes
var pI = app.activeDocument.pluginItems;
for(i=pI.length-1;i>=0;i--){
if(pI.tracing == "[TracingObject]") {
var curPI = pI; //Set object to variable so deselection also function
curPI.selected = true;
redraw();// redraw before for possible errors
app.executeMenuCommand("expandStyle");
redraw();// redraw before for possible errors
curPI.selected = false;
redraw();// redraw after for possible errors
}
}