Hi @Sayed Ali Mousawi,
I have written a script that will return all placed items in a document to 100% size with the option to position in relation to the placed item's frame (eg. the clipping mask rectangle). Will that work in your case?
- Mark
/*
UnScale All Placed Items.js
for Adobe Illustrator 2022
by m1b
here:https://community.adobe.com/t5/illustrator-discussions/change-placement-options-of-all-placeditems/m-p/12806572
*/
unScaleAllPlacedItems();
function unScaleAllPlacedItems(doc) {
doc = doc || app.activeDocument;
var items = doc.placedItems;
for (var i = 0; i < items.length; i++) {
unScalePlacedItem({
doc: doc,
item: items[i],
positionToFrame: Transformation.CENTER,
transformAbout: Transformation.CENTER
});
}
}
function unScalePlacedItem(options) {
var item = options.item,
positionToFrame = options.positionToFrame,
transformAbout = options.transformAbout;
if (options.item == undefined)
return;
// unscale the placed item
item.resize(1 / item.matrix.mValueA * 100, -1 / item.matrix.mValueD * 100, undefined, undefined, undefined, undefined, undefined, transformAbout);
if (positionToFrame == undefined)
return;
// get item's frame if it has one
var frame;
if (item.parent.constructor.name == 'GroupItem') {
for (var i = 0; i < item.parent.pageItems.length; i++) {
if (item.parent.pageItems[i].clipping == true) {
frame = item.parent.pageItems[i];
break;
}
}
}
if (frame == undefined)
return;
var centerDelta = differenceBetweenPoints(centerOfItem(frame), centerOfItem(item)),
topLeftDelta = differenceBetweenPoints([frame.left, frame.top], [item.left, item.top]),
sizeDelta = differenceBetweenPoints([frame.width, frame.height], [item.width, item.height]);
// position the placed item in relation to its frame
if (positionToFrame == Transformation.TOPLEFT) {
item.translate(topLeftDelta[0], topLeftDelta[1]);
}
else if (positionToFrame == Transformation.TOP) {
item.translate(centerDelta[0], topLeftDelta[1]);
}
else if (positionToFrame == Transformation.TOPRIGHT) {
item.translate(topLeftDelta[0] + sizeDelta[0], topLeftDelta[1]);
}
else if (positionToFrame == Transformation.LEFT) {
item.translate(topLeftDelta[0], centerDelta[1]);
}
else if (positionToFrame == Transformation.CENTER) {
item.translate(centerDelta[0], centerDelta[1]);
}
else if (positionToFrame == Transformation.RIGHT) {
item.translate(topLeftDelta[0] + sizeDelta[0], centerDelta[1]);
}
else if (positionToFrame == Transformation.BOTTOMLEFT) {
item.translate(topLeftDelta[0], topLeftDelta[1] - sizeDelta[1]);
}
else if (positionToFrame == Transformation.BOTTOM) {
item.translate(centerDelta[0], topLeftDelta[1] - sizeDelta[1]);
}
else if (positionToFrame == Transformation.BOTTOMRIGHT) {
item.translate(topLeftDelta[0] + sizeDelta[0], topLeftDelta[1] - sizeDelta[1]);
}
}
function centerOfItem(item) {
var hasDocCoordinates = app.coordinateSystem == CoordinateSystem.DOCUMENTCOORDINATESYSTEM;
var pos = hasDocCoordinates ? app.activeDocument.convertCoordinate(item.position, CoordinateSystem.DOCUMENTCOORDINATESYSTEM, CoordinateSystem.ARTBOARDCOORDINATESYSTEM) : item.position;
pos[0] += item.width / 2;
pos[1] -= item.height / 2;
return pos;
}
function differenceBetweenPoints(p1, p2) {
return [-(p2[0] - p1[0]), -(p2[1] - p1[1])];
}