Skip to main content
stevenpcurtis
Participant
October 15, 2019
Question

Add simple rectangle to group Illustrator script

  • October 15, 2019
  • 1 reply
  • 1373 views
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 = [00];

 

        currentLayer.hasSelectedArtwork = true;
        newimage.moveToBeginningimgGroup );
    
        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 ( 00imgWidthimgHeight);

 

       
myLayer.moveToBeginningimgGroup );
 
 
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"?
 
This topic has been closed for replies.

1 reply

renél80416020
Inspiring
October 15, 2019

Salut!

var doc = app.activeDocument;
var imgGroup = doc.groupItems.add();
 var rectRef = imgGroup.pathItems.rectangle(0,0,200,100);

Bon courage...