Question
Add simple rectangle to group Illustrator script
I'm trying to add my white rectangle to the same group as my placed image
var imgGroup = app.activeDocument.groupItems.add();
var newimage = doc.placedItems.add();
newimage.file = File(promoImages[i]);
newimage.position = [0, 0];
currentLayer.hasSelectedArtwork = true;
newimage.moveToBeginning( imgGroup );
var imgWidth = 200
var imgHeight = 278
newimage.width = imgWidth
newimage.height = imgHeight
// create white rectangle underneath the image
var myLayer = doc.activeLayer
myLayer.pathItems.rectangle ( 0, 0, imgWidth, imgHeight);
myLayer.moveToBeginning( imgGroup );
The final line generates an error,
as does trying to separate out the rectangle, as does everything else I can think of.
How can I add the rectangle to the group "imgGroup"?