// 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();
www.prog.co.il
www.prog.co.il
מעכשיו, תהיו הראשונים לקבל את כל העדכונים, החדשות, ההפתעות בלעדיות, והתכנים הכי חמים שלנו בפרוג!
חלה שגיאה בשליחה. נסו שוב!
לוח לימודים
מסלולי לימוד שאפשר להצטרף
אליהם ממש עכשיו:
תהילים פרק כה
אלְדָוִד אֵלֶיךָ יי נַפְשִׁי אֶשָּׂא:באֱלֹהַי בְּךָ בָטַחְתִּי אַל אֵבוֹשָׁה אַל יַעַלְצוּ אֹיְבַי לִי:גגַּם כָּל קוֶֹיךָ לֹא יֵבֹשׁוּ יֵבֹשׁוּ הַבּוֹגְדִים רֵיקָם:דדְּרָכֶיךָ יי הוֹדִיעֵנִי אֹרְחוֹתֶיךָ לַמְּדֵנִי:ההַדְרִיכֵנִי בַאֲמִתֶּךָ וְלַמְּדֵנִי כִּי אַתָּה אֱלֹהֵי יִשְׁעִי אוֹתְךָ קִוִּיתִי כָּל הַיּוֹם:וזְכֹר רַחֲמֶיךָ יי וַחֲסָדֶיךָ כִּי מֵעוֹלָם הֵמָּה:זחַטֹּאות נְעוּרַי וּפְשָׁעַי אַל תִּזְכֹּר כְּחַסְדְּךָ זְכָר לִי אַתָּה לְמַעַן טוּבְךָ יי:חטוֹב וְיָשָׁר יי עַל כֵּן יוֹרֶה חַטָּאִים בַּדָּרֶךְ:טיַדְרֵךְ עֲנָוִים בַּמִּשְׁפָּט וִילַמֵּד עֲנָוִים דַּרְכּוֹ:יכָּל אָרְחוֹת יי חֶסֶד וֶאֱמֶת לְנֹצְרֵי בְרִיתוֹ וְעֵדֹתָיו:יאלְמַעַן שִׁמְךָ יי וְסָלַחְתָּ לַעֲוֹנִי כִּי רַב הוּא:יבמִי זֶה הָאִישׁ יְרֵא יי יוֹרֶנּוּ בְּדֶרֶךְ יִבְחָר:יגנַפְשׁוֹ בְּטוֹב תָּלִין וְזַרְעוֹ יִירַשׁ אָרֶץ:ידסוֹד יי לִירֵאָיו וּבְרִיתוֹ לְהוֹדִיעָם:טועֵינַי תָּמִיד אֶל יי כִּי הוּא יוֹצִיא מֵרֶשֶׁת רַגְלָי:טזפְּנֵה אֵלַי וְחָנֵּנִי כִּי יָחִיד וְעָנִי אָנִי:יזצָרוֹת לְבָבִי הִרְחִיבוּ מִמְּצוּקוֹתַי הוֹצִיאֵנִי:יחרְאֵה עָנְיִי וַעֲמָלִי וְשָׂא לְכָל חַטֹּאותָי:יטרְאֵה אוֹיְבַי כִּי רָבּוּ וְשִׂנְאַת חָמָס שְׂנֵאוּנִי:כשָׁמְרָה נַפְשִׁי וְהַצִּילֵנִי אַל אֵבוֹשׁ כִּי חָסִיתִי בָךְ:כאתֹּם וָיֹשֶׁר יִצְּרוּנִי כִּי קִוִּיתִיךָ:כבפְּדֵה אֱלֹהִים אֶת יִשְׂרָאֵל מִכֹּל צָרוֹתָיו:
הנושאים החמים