Script error: property 'duplicate'

Hello,

I am trying to write my new script. Could someone please help? Also, are there any simple tutorials for Scripts in CorelDraw somewhere? Thank you in advance.

This supposed to duplicate an object and randomly rotate it and make rows of it:

object = host.activeDocument.selection[0];

for(j=0; j<10; j++)
{
//make a row
for (i = 0; i < 10; i++)
{
newobject = object.duplicate();
newobject.translate(object.width * (i + 1), -object.height * (j + 1));
newobject.rotate(Math.floor(Math.random() * 4) * 90);
}
}

Parents
  • {
    let object = host.activeSelection;
    let x = object.positionX;
    let y = object.positionY;
    let w = object.sizeWidth;
    let h = object.sizeHeight;

    for(j=0; j < 10; j++)
    {
    for (i = 0; i < 10; i++)
    {
    let newobject = object.duplicate();
    newobject.setPosition(x + w * (i + 1),y -h * (j));
    newobject.rotate(Math.floor(Math.random() * 4) * 90);
    }
    }
    }
Reply Children
No Data