Copy link to clipboard
Copied
Script to select a specific link and an object style to apply to.
It searches document and applies the style to all frames contents that link.
Something like this maybe?
(comments from experts are more than welcome)
...// [310718] Link2ObjectStyle
// Apply object style to graphic frames in regard to linked file name
// written by Vinny
if (parseFloat(app.version) < 6) {
main();
} else {
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Link2ObjectStyle");
}
function main() {
if (app.do
Copy link to clipboard
Copied
What did you try so far?
Show us some code we can comment on.
Regards,
Uwe
Copy link to clipboard
Copied
Something like this maybe?
(comments from experts are more than welcome)
// [310718] Link2ObjectStyle
// Apply object style to graphic frames in regard to linked file name
// written by Vinny
if (parseFloat(app.version) < 6) {
main();
} else {
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Link2ObjectStyle");
}
function main() {
if (app.documents.length > 0) {
//------------
//Variables
var
myDoc = app.documents[0],
myObjectStyles = myDoc.objectStyles.everyItem(),
myLinks = myDoc.allGraphics;
//------------
//Dialog box
var myDialog = app.dialogs.add({
name: "Apply object style to graphic frames in regard to linked file name",
canCancel: true
});
with(myDialog) {
with(dialogColumns.add()) {
with(borderPanels.add()) {
with(dialogColumns.add()) {
staticTexts.add({
staticLabel: "File name contains:"
});
}
with(dialogColumns.add()) {
var myTextEditField = textEditboxes.add({});
}
}
with(borderPanels.add()) {
with(dialogColumns.add()) {
staticTexts.add({
staticLabel: "Apply object style:"
});
}
with(dialogColumns.add()) {
var myObjectStylesMenu = dropdowns.add({
stringList: myObjectStyles.name,
selectedIndex: 0
});
}
}
}
if (myDialog.show() == true) {
var myString, myObjectStyle, myObjectStylesMenu, fileName, j = 0;
myString = myTextEditField.editContents;
myObjectStyle = myDoc.objectStyles[myObjectStylesMenu.selectedIndex];
myDialog.destroy();
//------------
//let's rock
if (myString == "") {
alert("you didn't enter any string");
return null;
} else {
for (i = 0; myLinks.length > i; i++) {
if (myLinks.itemLink.name.search(myString) != -1) {
myLinks.parent.applyObjectStyle(myObjectStyle);
j++;
}
}
//------------
//end
if (j == 0) {
alert("String could not be found\nScript ends");
} else {
alert(j + " objects found.\nYou're done");
}
}
} else {
myDialog.destroy()
}
}
} else {
alert("Open a document");
return null
}
}
Copy link to clipboard
Copied
Hi Vinny,
if you want also object styles in style groups loop the allObjectStyles array of the document to gather your string list.
Regards,
Uwe
Copy link to clipboard
Copied
Good point, thanks ^^
Copy link to clipboard
Copied
Not tried it yet, but gif shows even more than what I had in mind!!
It can even find certain extention of file or any kind of text that contains in the file name! looks amazing! Now time to talk about those Strawberries and potatos!! Or even grapefruits and ... bananas... maybe!
Copy link to clipboard
Copied
I don't know coding and start it here to find some help with that matter.
Vinny tried some codes, I run it asap and reply soon.
Don't know if I started this disscusion in right forum! sorry!