Issue grouping objects together using a script
Hello everyone,
After importing a PDF using my extended script for illustrator, I want to apply a warp effect to the three designs it contains. Visually, these designs are separated by a line and they occupy exactly a third of the PDF each. In the image below you can see an example of what this PDF might look like, note that I have selected the middle design and that I am hovering a star so that you can see that the design is not an image, but a composition of several SVG elements (GroupItem).

The issue I am having is selecting this path (I am referring to the "bounding box" of the design) in my script, if I iterate through all GroupItem or PathItem elements I cannot find any that matches this selection (looking at things like width and height). I have tried creating three GroupItem variables and storing all the PathItem elements in these depending on where they are located in the y-axis:
var fileRef = new File(myPath + "mug_canvas_3.pdf");
if (fileRef != null) {
var docRef = open(fileRef, DocumentColorSpace.RGB, );
}
var docH = docRef.height;
var docW = docRef.width;
var ref1 = docH/3, ref2 = 2*docH/3;
var numPathItems = docRef.placedItems.length;
$.writeln('docH: ' + docH + " docW: " + docW
+ " ref1: " + ref1 + " ref2: " + ref2
+ " num path items: " + numPathItems);
var i, docPI = docRef.pathItems;
var g1 = docRef.groupItems.add(),
g2 = docRef.groupItems.add(),
g3 = docRef.groupItems.add();
for(i = 0; i < numPathItems; i++) {
var pi = docPI[i];
if(pi.controlBounds[3] < ref1) {
g1.moveToEnd(pi);
} else if(pi.controlBounds[3] < ref1) {
g2.moveToEnd(pi);
} else {
g3.moveToEnd(pi);
}
//$.writeln('# PI ' + i + " bottomLeft: " + pi.controlBounds[3]);
}
$.writeln("G1: " + g1.pathItems.length)
$.writeln("G2: " + g2.pathItems.length)
$.writeln("G3: " + g3.pathItems.length)
However, the .moveToEnd function does not seem to work because it gives me this error:
--> "the new object cannot be created at the specified location"
If anything is not clear please let me know. I have a script that works for embedding a PDF as a groupItem and then applying the warp, but I want to apply three separate warps, one to each design. If you want to see the desired output I can of course share that too.
I would very much appreciate any help.
Thank you very much!

