Copy link to clipboard
Copied
Hi,
I want use : fit(FitOptions.FRAME_TO_CONTENT) to only rectangles having placed an image of any type, not to touching other rectangles
I' don't know how to do it.
Many thanks for suggestions 🙂
Marcin
Copy link to clipboard
Copied
Hi,
try this snippet.
var doc = app.documents[0];
var rects = doc.rectangles;
for (var i=0, len=rects.length; i < len ; i++) {
var rect = rects;
var include_img = rect.graphics.length > 0 ||
rect.images.length > 0;
if (include_img) {
$.writeln(rect.id);
rect.fit(FitOptions.FRAME_TO_CONTENT);
}
};
if you want to specify graphic type, use rect.epss.length instead of rect.graphics.length for example.
thankyou
mg
Copy link to clipboard
Copied
Hi Marcin,
if you also want to catch graphics, that are nested (in groups, anchored graphics, graphics in cells, pasted inside graphics) we could also use the allGraphics array of the document. Then the question is: would you like to dismiss graphics on locked layers, graphics that are locked, graphics that are placed on the pasteboard * ?
// Fit graphics, if parent is Rectangle object
// Dismiss locked rectangles and locked layers
var doc = app.documents[0];
var allGraphicsArray = doc.allGraphics;
for(var n=0;n<allGraphicsArray.length;n++)
{
var container = allGraphicsArray
.parent;
if(
// 1. Container is a Rectangle object:
container.constructor.name == "Rectangle"
// 2. It's layer is not locked:
&& container.itemLayer.locked === false
// 3. Container is not locked:
&& container.locked === false
)
{
allGraphicsArray
.parent.fit(FitOptions.FRAME_TO_CONTENT); };
};
* If only placed graphics of the pages should be affected, we could loop through the pages.
What could go wrong?
The container of the graphic is inside overset text or is part of a table cell's overset.
Uwe
Copy link to clipboard
Copied
many thanks milligrame
it looks like needed !!
I will try tommorow in practice
thank you Laubender
tommorow I will try it
Copy link to clipboard
Copied
many, many many thanks Launder 🙂
your snippet looks and work brilliant !!!!
it gave me also a "new" look of "what" I should search first 🙂
thanks again
regards Marcin