Hi All,
I'm have a great deal of trouble with this.
I can get the visible bounds of a simple item or group of items.
the Script for this is:
//Get Size for all selected items/groups
doc = app.activeDocument;
sel = doc.selection;
TOmm = 2.83466796875;
Dim(sel);
function Dim(objs) {
for (i=objs.length-1;i>=0;i--) { // loop through your collection of objects
var bounds = objs[i].visibleBounds; // Get visibal bounds, which are only visable bounds in some cases...
var b1 = bounds[0] /TOmm;
var b2 = bounds[1] /TOmm;
var b3 = bounds[2] /TOmm;
var b4 = bounds[3] /TOmm;
var W = Math.abs(b3-b1).toFixed(1);
var H = Math.abs(b4-b2).toFixed(1);
txt = doc.textFrames.add(); // Create the text frame
txt.contents = "Size: "+ H + " x " +W + " mm W"; // Adds contents to frame
txt.position = [objs[i].left,objs[i].top - objs[i].height - 20]; // Positions the frame
}; };
I can get the correct size for simple ClipGroups.
Script below:
//Get Size for all selected "simple" ClipGroups
doc = app.activeDocument;
grp = doc.groupItems;
TOmm = 2.83466796875;
Dim(grp);
function Dim(objs) {
for (i=objs.length-1;i>=0;i--) { // loop through total collection of groupItems
if (objs[i].selected) { // test if groupItem is selected
if(objs[i].pathItems[0].clipping==true){
var bounds = objs[i].pathItems[0].visibleBounds; // Get visibal bounds, which are only visable bounds in some cases...
var b1 = bounds[0] /TOmm;
var b2 = bounds[1] /TOmm;
var b3 = bounds[2] /TOmm;
var b4 = bounds[3] /TOmm;
var W = Math.abs(b3-b1).toFixed(1);
var H = Math.abs(b4-b2).toFixed(1);
txt = doc.textFrames.add(); // Create the text frame
txt.contents = "Size: "+ H + " x " +W + " mm W"; // Adds contents to frame
txt.position = [objs[i].left,objs[i].top - objs[i].height - 20]; // Positions the frame
}; }; }; };
I don't think merging these into one script would be hard.
if the clip groups clipping path is not the first item I can loop the path items to find it.
its the more complex items I can't get a handle on.
Questions:-
How to deal with multiple Cilp Groups within Clip Groups?
here is a link to a zip file containing the above 2 scripts.
and a test file with some shapes in it.
http://qwertyfly.com/files/Size.zip
top two rows of shapes work fine with Size.jsx
first item on the bottom row works with ClipSize.jsx
second item on bottom row would work with ClipSize.jsx, if I added a loop through "pathItems".
Last Item on Bottom row has me stumped...
does not matter which clip group is measured, both would be wrong.
and this is still quite a simple shape...
Any help with this would be great.
Thanks guys...