- הוסף לסימניות
- #1
מצאתי כאן סקריפט שיכול להיות שימושי, דא עקא. שיש לו בעיה בשורה מסוימת.
אם מישהו יוכל לתקנה. זה יהיה נחמד לציבור
הסקריפט מוחק אובייקטים לפי סגנון פסקה
מצורף הקוד המלא
אם מישהו יוכל לתקנה. זה יהיה נחמד לציבור
הסקריפט מוחק אובייקטים לפי סגנון פסקה
מצורף הקוד המלא
JavaScript:
// REMOVE ALL OBJECTS WITH A CERTAIN OBJECT STYLE
// Copyright (c) 2018 Mads Wolff
// This script is distributed under the MIT License.
// MAIN FUNCTIONALITY
// Make a reference to the Object Styles of the active document.
var objectStyles = app.activeDocument.objectStyles;
// Make a reference to the Page Items of the active document.
var pageItems = app.activeDocument.allPageItems;
// Removes all Objects with a certain Object Style.
// Takes 2 arguments:
// objectStyleName the name of the Object Style
// removeFrom the kind of Spreads to apply to (0: all, 1: only normal Spreads, 2: only Master Spreads)
function removeAllObjectsWithACertainObjectStyle(objectStyleName, removeFrom) {
// Iterate through the Page Items.
// (Since we are going to delete some of the items while iterating, we need to "loop backwards".)
for (i = pageItems.length- 1; i >= 0; i--) {
// Make a reference to the Page Item.
var pageItem = pageItems[i];
// Make a reference to the Page Item's Spread type
var spreadType = pageItem.parentPage.parent.constructor.name;
// Check if the Page Item has the right Object Style and Spread type.
if (
pageItem.appliedObjectStyle.name === objectStyleName &&
(removeFrom === 0 || (removeFrom === 1 && spreadType === "Spread") || (removeFrom === 2 && spreadType === "MasterSpread"))
) {
// Remove the Page Item.
pageItem.remove();
}
}
}
// DIALOG
// Stores all the names of the document's Object Styles in an array.
function getObjectStylesNames() {
var objectStyleNames = new Array;
for (i = 0; i < objectStyles.length; i++){
objectStyleNames.push(objectStyles.item(i).name);
}
return objectStyleNames;
}
// Displays the input dialog.
function displayDialog(){
var dialog = app.dialogs.add({name:"Remove all Objects with a certain Object Style"});
var objectStyleNames = getObjectStylesNames();
with (dialog) {
with (dialogColumns.add()) {
with (borderPanels.add()) {
with (dialogColumns.add()) {
staticTexts.add({staticLabel:"Object Style:"});
staticTexts.add({staticLabel:"Remove from:"});
}
with (dialogColumns.add()) {
var objectStyleNameDropdown = dropdowns.add({stringList: objectStyleNames, selectedIndex: 0, minWidth: 200});
var radiobuttonGroup = radiobuttonGroups.add();
with (radiobuttonGroup) {
radiobuttonControls.add({staticLabel: "All Spreads", checkedState: true})
radiobuttonControls.add({staticLabel: "Normal Spreads only"})
radiobuttonControls.add({staticLabel: "Masters Spreads only"})
}
}
}
with (borderPanels.add()) {
}
}
}
var dialogReturn = dialog.show();
if (dialogReturn == true) {
var objectStyleName = objectStyleNames[objectStyleNameDropdown.selectedIndex];
var removeFrom = radiobuttonGroup.selectedButton;
dialog.destroy();
removeAllObjectsWithACertainObjectStyle(objectStyleName, removeFrom);
} else {
dialog.destroy();
}
}
displayDialog();
הנושאים החמים