Mobile app version of vmapp.org
Login or Join
Reiling762

: Frame around the selected area to the script in Illustrator var idoc = app.activeDocument; var sel = idoc.selection; var blk_color = new CMYKColor(); blk_color.cyan = 100; for (i=0;

@Reiling762

Posted in: #IllustratorScripting

var idoc = app.activeDocument;

var sel = idoc.selection;

var blk_color = new CMYKColor();
blk_color.cyan = 100;


for (i=0; i<sel.length; i++)

{
var pgItem = sel[i];
var bounds = pgItem.geometricBounds;

var ipath = idoc.pathItems.rectangle
(pgItem.position[1],
pgItem.position[0],
pgItem.width,
pgItem.height);

ipath.stroked = true;
ipath.strokeColor = blk_color;
ipath.filled = false;
ipath.strokeWidth = 5;
ipath.strokeDashes = [10];
}

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Reiling762

1 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi706

The rectangle method of pathItems takes the parameters (top,left,width,height) so all you need to do is offset those values accordingly.

Illustrator works exclusively with points so you need to convert the value from mm to points. 2.834645 points = 1 millimeter so...

15mm = 42.52point (rounded to 2 decimal places)

This should work:

var ipath = idoc.pathItems.rectangle(
pgItem.position[1]+42.52,
pgItem.position[0]-42.52,
pgItem.width+85.04,
pgItem.height+85.04);

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme