• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Ideas welcome (to think of a way to help user find specific images)

Advocate ,
Mar 15, 2018 Mar 15, 2018

Copy link to clipboard

Copied

Hello Automators,


we have a new DAM, and we have tons of documents which hold our old images+text-compositions as kind of a copy/paste-database. Poor enough, but we need to exchange old images to our new assets in the DAM by hand. (…because the DAM got cleaned up and new assets arent mappable)

Im pulling off a script for my collegues that scans thru InDesigns links for a specific part of the file path. Everything that didnt match, is a "old" link.

Now my question, because I doubt I coul do this without scripting further:
What would you do, if you have an array of indesign-links and you want to "highlight" them?

  • I managed to make a new document and listed them, but because our documents hold 500+ links, a single page as reference isnst enough and leaves the user searching the page.
  • I could imagine creating a new layer with flashy copys of the images container-box
  • Or maybe I can tag somewhere them and use the InD find-dialog somehow
  • Or maybe I dont know yet of a easy-to-use indicator provided by InDesign (like the previous hidden feature to highlight format differences)

But maybe you, creators of lots of fine tools, have a awesome idea to make these images pop up/stand out/are referenced.

(On the screenshot youll notice that our typical document in the background has too many images on each page to just differ by page. Also my script is not finished (eg have to sort array sort by page), because im kinda unsatisfied with the output…)

Bildschirmfoto 2018-03-15 um 10.55.04.png

TOPICS
Scripting

Views

942

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Mar 15, 2018 Mar 15, 2018

Here is a new version,

1) Auto refresh if a selection change occurs (including switching from doc to another)

2) Copy file name to clipboard

3) zoom less closer

#targetengine 'linksExplorer'

//Main routine

var main = function() {

var doc = app.properties.activeDocument,dlg, linksData,

callback;

if ( !doc ) return;

this.dlg = this.dlg || ui();

this.dlg.show();

}

//Retrieve doc links

function getLinks(){

const uris = [

"srvmar16.zentrale.ad.local",

"192.168.96.116",

"Macintosh"

];

var ls, n = 0, l, o = {}, lid,

doc =

...

Votes

Translate

Translate
People's Champ ,
Mar 15, 2018 Mar 15, 2018

Copy link to clipboard

Copied

Hi,

I am not sure if you are looking more into a logging process as your document seems to indicate or if you want a quick way to loop through the document to introspect problematic links.

If the  former I am guessing, smartReflow may be useful to expand data over the first page. If the latter, maybe I can sugget a simple UI to navigate through links inside the doc ? You will need to refine the links collection to include only links with problematic urls.

HTH

Loic

#targetengine 'linksExplorer'

//Main routine

var main = function() {

var doc = app.properties.activeDocument,dlg, linksData,

callback;

if ( !doc ) return;

linksData = getLinks(doc);

callback = function(id){

var theObj = linksData[id];

if ( !theObj ) return;

zoomObject(theObj.container);

}

this.dlg = this.dlg || ui(linksData, callback);

this.dlg.show();

}

//Retrieve doc links

function getLinks(doc){

var ls = doc.links.everyItem().getElements(), n = ls.length, l, o = {}, lid;

while ( n-- ) {

l = ls;

lid = l.id;

o[lid] = {name:l.name, id:lid, container:l.parent.parent};

}

return o;

}

//UI build function

var ui = function (oLinksData, callback){

var u,

w = new Window('palette'),

ls = w.add('listbox'),

btn = w.add('button',u,"Quit"),

linkItem, listItem;

for ( prop in oLinksData ) {

linkItem = oLinksData[prop];

listItem = ls.add('item', linkItem.name);

listItem.id = linkItem.id;

}

btn.onClick = function(){w.close(0)};

ls.onChange = function() {

if ( !ls.selection ) return;

callback ( ls.selection.id );

}

return w;

};

//Created by Dave Saunders > http://jsid.blogspot.fr/2006/01/zoom-in-on-object.html

function zoomObject(theObj) {

try {

  var objBounds = theObj.geometricBounds;

} catch (e) {

  throw "Object doesn't have bounds."

}

var ObjHeight = objBounds[2] - objBounds[0];

var ObjWidth = objBounds[3] - objBounds[1];

var myWindow = app.activeWindow;

var pageBounds = myWindow.activePage.bounds;

var PgeHeight = pageBounds[2] - pageBounds[0];

var PgeWidth = pageBounds[3] - pageBounds[1];

var hRatio = PgeHeight/ObjHeight;

var wRatio = PgeWidth/ObjWidth;

var zoomRatio = Math.min(hRatio, wRatio);

app.select(theObj); // to make active the page that holds theObj

myWindow.zoom(ZoomOptions.fitPage);

myWindow.zoomPercentage = myWindow.zoomPercentage * zoomRatio;

exit() // Because there's no point in doing this if you don't exit to let the user see

}

var u;

app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );

Capture d’écran 2018-03-15 à 11.49.35.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 15, 2018 Mar 15, 2018

Copy link to clipboard

Copied

Thank you for this post. It quite a good approach. But I would have to customize your code alot, and because Im not very fluid in jsx and I started this with braindead-applescript, I dont want you to do all that work for me. That would be alot.

But maybe, coming from thinking with my unskilled coder mind, it isnt such a big whoop for a skilled programmer like you, so Ill point out what my improvements would be:

- If I look at your code, I doubt that Im able to simply examine the file path of the links for "srvmar16.zentrale.ad.local" or "192.168.96.116" string. Also I need that as a constant/property at the top of the code in an array, because I have to change that maybe later, or maybe just add a string. If one of these matches, its a bad egg, and has to go on my "linklist".

- My matching-linkslist can be up to 300 entrys long, if someones work was sloppy. The window should be set to a fixed size to not bloat my full height. That would be easy.

- The final task for the user now is to exchange these links with a new image from the DAM by hand. The DAM-InDesign-Plugin is a bit sloppy too, cant be scripted nor envoked.
The workaround now is to copy filename from link palette, cleaning the suffix, and paste it into the DAM-Plugin, and drag'n'drop the new asset onto the document image.


So, there is not very much customization, but too much to just alter your code.

So, imagine its a piece of cake for you, and that would be no problem, the next steps would be:

Upon Klick on name of image in pallette:

     - goto/show image in document. Thats what it does right now, but dont zoom in that much

     - copy image file name without suffix to copypasteboard

Thats nearly it Only thing: What if I exchange a link and now that asset in the list doesnt match the filter anymore, is it possible to refresh the pallette after each mouseklick? And if so, while having 300 entrys in that list, would the refresh reset the item i scrolled to and reset to show from top?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 15, 2018 Mar 15, 2018

Copy link to clipboard

Copied

Just a thing I stumpled upon: Maybe you could get rid of Daves function by calling…

Bildschirmfoto 2018-03-15 um 15.22.47.png

"Fit selection to window"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 15, 2018 Mar 15, 2018

Copy link to clipboard

Copied

Here is a new version,

1) Auto refresh if a selection change occurs (including switching from doc to another)

2) Copy file name to clipboard

3) zoom less closer

#targetengine 'linksExplorer'

//Main routine

var main = function() {

var doc = app.properties.activeDocument,dlg, linksData,

callback;

if ( !doc ) return;

this.dlg = this.dlg || ui();

this.dlg.show();

}

//Retrieve doc links

function getLinks(){

const uris = [

"srvmar16.zentrale.ad.local",

"192.168.96.116",

"Macintosh"

];

var ls, n = 0, l, o = {}, lid,

doc = app.properties.activeDocument, reg;

if ( !doc ) return o;

reg = new RegExp( "^("+uris.join("|")+").+", "i" );

ls = doc.links.everyItem().getElements();

n = ls.length;

while ( n-- ) {

l = ls;

if ( !reg.test( l.filePath) ) continue;

lid = l.id;

o[lid] = {name:l.name+" ("+l.id+")", id:lid, container:l.parent.parent};

}

return o;

}

//UI build function

var ui = function (){

var u,

w = new Window('palette', $.engineName),

ls = w.add('listbox'),

btn = w.add('button',u,"Quit"),

linkItem, listItem,

updateLinksList = function() {

var data, linkData, listItem;

ls.removeAll();

data = getLinks();

if ( !data.__count__ ) return;

for ( prop in data ) {

linkData = data[prop];

listItem = ls.add('item', linkData.name);

listItem.data = linkData;

}

}, ev = app.eventListeners.itemByName ( "onSelectionChanged" );

w.alignChildren = ["fill","fill"];

ls.preferredSize = [200,350];

ls.maximumSize.height = 500;

btn.onClick = function(){w.close(0)};

ls.onChange = function() {

if ( !ls.selection ) return;

zoomObject ( ls.selection.data.container );

SetClipboard ( ls.selection.data.name.replace ( /\.[a-z]+$/i, '') );

}

w.onShow = function(){

updateLinksList();

}

if ( !ev.isValid ) {

app.eventListeners.add("afterSelectionChanged",function(evt){

updateLinksList();

});

}

return w;

};

//Created by Dave Saunders > http://jsid.blogspot.fr/2006/01/zoom-in-on-object.html

function zoomObject(theObj) {

try {

  var objBounds = theObj.geometricBounds;

} catch (e) {

  throw "Object doesn't have bounds."

}

var ObjHeight = objBounds[2] - objBounds[0];

var ObjWidth = objBounds[3] - objBounds[1];

var myWindow = app.activeWindow;

var pageBounds = myWindow.activePage.bounds;

var PgeHeight = pageBounds[2] - pageBounds[0];

var PgeWidth = pageBounds[3] - pageBounds[1];

var hRatio = PgeHeight/ObjHeight;

var wRatio = PgeWidth/ObjWidth;

var zoomRatio = Math.min(hRatio, wRatio);

app.select(theObj); // to make active the page that holds theObj

myWindow.zoom(ZoomOptions.fitPage);

myWindow.zoomPercentage = myWindow.zoomPercentage; // * zoomRatio;

}

//See here for reference :

//https://forums.adobe.com/thread/2203330

function SetClipboard(clip){ 

    var clipboard; 

    if(File.fs == "Macintosh"){ 

        app.doScript ('tell application "Finder" to set the clipboard to "'+clip+'"',ScriptLanguage.APPLESCRIPT_LANGUAGE); 

    } else { 

       app.doScript ( 'Dim theObject\r Set theObject = CreateObject (\"htmlfile\")\r Call theObject.ParentWindow.ClipboardData.SetData(\"text\",\"'+clip+'\")', ScriptLanguage.visualBasic );

    } 

    return; 

main();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

That, Loic.Aigon​ is fine piece of work you done there for me, and I want to thank you in all ways for that!
I'm with you: when I stumble upon something about InDesign I could answer here, I like to help and share when I got time on my hands, which makes me feel valuable and good. Because sitting at work and watching my collegues doing redundant tasks not-knowing/not-willing to enhance their workflow and go home in time makes me sad and I want to help wherever I can script a tool that helps.

So again, thank you.

But one thing has to be fixed, to make it work probably, because I dont really understand your/js efficient syntax here:

function getLinks(){ 

     

const uris = [ 

"srvmar16.zentrale.ad.local", 

"192.168.96.116"]; 

   

var ls, n = 0, l, o = {}, lid, 

doc = app.properties.activeDocument, reg; 

     

if ( !doc ) return o; 

     

reg = new RegExp( "^("+uris.join("|")+").+", "i" ); 

     

ls = doc.links.everyItem().getElements(); 

n = ls.length; 

     

while ( n-- ) { 

l = ls

if ( !reg.test( l.filePath) ) continue; 

lid = l.id; 

o[lid] = {name:l.name, id:lid, container:l.parent.parent}; 

I need the script to get all links and exclude links matching any of const uris values.
I already successfully managed to maipulate the strings/names in the listbox to not show (and copy) the id

One more question: How is focus handeld with js-palettes (only done some 'windows')? Is it possible to get the focus on the selection in document? If I click a name, the asset gets selected, but I cant just press cmd+x without clicking somewhere into the document.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Hi,

I need the script to get all links and exclude links matching any of const uris values.

Then just negate the regexp evaluation

if ( reg.test( l.filePath) ) continue;   

I already successfully managed to maipulate the strings/names in the listbox to not show (and copy) the id

Yes I added ids to differentiate similarly named links but yes everything is possible at this point and ids may not be obvious to people.

How is focus handeld with js-palettes (only done some 'windows')?

It seems like I can't unfocus the palette. Nor w.active=false; nor app.activate; looses palette focus. Sorry but it seems you will have to click on app UI anyway or create a CEP panel maybe to solve this one.

Unless I am wrong…

Glad it helped. And yes I share this same lack of interest for redundant and time consuming tasks

Loic

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

I need the script to get all links and exclude links matching any of const uris values.

Hi Jan,

then remove the ! in the if statement of the while loop.

You could also write the if statement this way:

if( l.filePath.match( reg ) ){ continue };

Does that make sense?

Regards,
Uwe

PS: Loic was faster… 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Thanks to both of you! InDesigns great community can depend on you experts!

Maybe within the future lets say my job gets reduced, I could imagine to become a more technical automation InDesign cosultant or something rather than a designer(-drone). But I never "learned" that and dont know how to switch, and Germany has this problem, that you arent worth something if you dont have a certificate for that – skills are valued less worth than certificates.

But since our company still thinks they are too big to fail, I dont plan for a change in jobs in near future, and tend to do less what I love to pay off my small house.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

Hello world,

in case, somebody wants to work with that code too:

I found out, that because Loic utilized GREP to find my strings within the filepath and…

  1. const uris = [ 
  2. "srvmar16.zentrale.ad.local", 
  3. "192.168.96.116", 
  4. "Macintosh" 
  5. ]; 

…therefor I need to keep the GREP sytax for my strings and eg escape the .

"srvmar16\.zentrale\.ad\.local",  

And again: Big Kudos to Loic.Aigon

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 19, 2018 Jun 19, 2018

Copy link to clipboard

Copied

LATEST

Hi Loic.Aigon​, its been a while since you helped me out alot, but I have to ask for some tiny help again. While I at my job was well under fire, i was able to do some slight modificationsn to our needs, but one things I cant solve:

I understand that selecting an item from the listbox triggers an event (onSelectionChange/AfterSelectionChange) which calls the updateLinklist(), which fetches new linklist, and then refreshes the main window…

While doing this, I wanted to try to preselect the previous item (to actually 'keep' it visually selected). So I saved the value to mySel*. But after setting ls.selection = temp, the selectionChange event kicks in again, with the zooming and name2clipboard, and also deselecting/refreshing the linklist. This is the point, where I cant follow your slick code, with functions in function with eventlisteners and all that palette-stuff.

Can you quickly point out where to set the listbox selection after zooming?

*because Im no programmer, I dont know how to use the ESTK probably, so I dont know how to log variables and data, so I appended a statictext ttext below my buttons, to watch if the selection is stored correctly, which it does.

#targetengine '123'

var ProgrammName = "DAM Check";

var myVersion = "0.2.180615"

var maxlinks, currentlinks,mySel;

app.scriptPreferences.enableRedraw = true;

mySel=-1;

function sortByKey(array, key) {

    return array.sort(function(b, a) {

        var x = a[key]; var y = b[key];

        return ((x < y) ? -1 : ((x > y) ? 1 : 0));

    });

}

     

    //Main routine 

    var main = function() { 

    var doc = app.properties.activeDocument,dlg, linksData, n, 

    callback;

    if ( !doc ) return;

    maxlinks = app.properties.activeDocument.links.everyItem().getElements().length;

    currentlinks = ( getLinks().__count__ );

    this.dlg = this.dlg || ui(); 

    this.dlg.show(); 

    } 

     

     

    //Retrieve doc links 

    function getLinks(){

       

    const uris = [ 

    "srvmar16\.zentrale\.ad\.local", 

    "192\.168\.96\.116"];       

       

    var ls, n = 0, l, o = {}, lid, 

    doc = app.properties.activeDocument, reg; 

     

    if ( !doc ) return o; 

     

    reg = new RegExp( "("+uris.join("|")+")", "i" ); 

     

    ls = doc.links.everyItem().getElements();

    n = ls.length; maxlinks = n;

    sortByKey(ls, "name");

   

    while ( n-- ) { 

    l = ls;

    if ( reg.test( l.filePath) ) continue; 

   

    try {

     Ort = l.parent.parentPage.name;

     } catch(err) {Ort = "MF"};

    

    lid = l.id;

    o[lid] = {name:l.name, id:lid, container:l.parent.parent,onPage:Ort};

    }

    return o; 

    } 

     

    //UI build function

    var ui = function (){ 

    var u, 

    w = new Window('palette', ProgrammName+"["+$.engineName+"]"), 

    ls = w.add('listbox',undefined,undefined,{selection: mySel, numberOfColumns: 2, showHeaders: true, columnTitles: ["Seite", "Name"]}), 

    grp = w.add('group'),

    pbar = grp.add ('progressbar', undefined, 0, maxlinks),

    t1 = grp.add ('statictext', undefined, "999/999 ➜ 100 %"),

    bgrp = w.add('group'),

    btn1 = bgrp.add('button',u,"Über"),

    btn2 = bgrp.add('button',u,"Schließen"),

    ttemp = w.add('statictext', undefined, "listitem = 999"),

    linkItem, listItem,

    updateLinksList = function() { 

     

    var data, linkData, listItem; 

    ttemp.text = ""+mySel;

    ls.removeAll();

    data = getLinks();

    t1.text = ""+currentlinks+ "/"+maxlinks+" ➜ "+Math.round((100 - (((100 / maxlinks) * currentlinks))))+" %";

    pbar.maxvalue = maxlinks;

    pbar.value = maxlinks - currentlinks;

    w.update();

    if ( !data.__count__ ) return; 

     currentlinks = ( data.__count__ );

    for ( prop in data ) { 

    linkData = data[prop]; 

    listItem = ls.add('item', linkData.onPage);

    listItem.subItems[0].text = linkData.name;

    listItem.data = linkData; 

    };

    }, ev = app.eventListeners.itemByName ( "onSelectionChanged" ); 

     

     

    w.alignChildren = ["fill","fill"];

    grp.alignChildren = ["fill","fill"];

    bgrp.alignChildren = ["fill","fill"];

    ls.preferredSize = [300,200]; 

    ls.maximumSize.height = 300;

    pbar.preferredSize = [400,2];

    pbar.maxvalue = maxlinks;

    pbar.value = maxlinks - currentlinks;

    t1.characters = 16;

    t1.justify = "right";

     

    btn2.onClick = function(){w.close(0)};

    btn1.onClick = function(){alert("work in progress")};

     

    ls.onChange = function() { 

    if ( !ls.selection ) return;

    mySel = ls.selection;

    t1.text = ""+currentlinks+ "/"+maxlinks+" ➜ "+Math.round((100 - (((100 / maxlinks) * currentlinks))))+" %";

    zoomObject ( ls.selection.data.container );

    SetClipboard ( ls.selection.data.name.replace ( /\.[a-z]+$/i, '') );

    } 

     

    w.onShow = function(){ 

    updateLinksList();

    } 

     

     

    if ( !ev.isValid ) { 

    app.eventListeners.add("afterSelectionChanged",function(evt){ 

    updateLinksList();

    t1.text = ""+currentlinks+ "/"+maxlinks+" ➜ "+Math.round((100 - (((100 / maxlinks) * currentlinks))))+" %";

    pbar.maxvalue = maxlinks;

    pbar.value = maxlinks - currentlinks;

    }); 

    } 

    return w; 

    }; 

     

     

    //Created by Dave Saunders > http://jsid.blogspot.fr/2006/01/zoom-in-on-object.html 

    function zoomObject(theObj) { 

     try { 

      var objBounds = theObj.geometricBounds; 

     } catch (e) { 

      throw "Objekt hat keine Abmessungen." 

     } 

     var ObjHeight = objBounds[2] - objBounds[0]; 

     var ObjWidth = objBounds[3] - objBounds[1]; 

     var myWindow = app.activeWindow; 

     var pageBounds = myWindow.activePage.bounds; 

     var PgeHeight = pageBounds[2] - pageBounds[0]; 

     var PgeWidth = pageBounds[3] - pageBounds[1]; 

     var hRatio = PgeHeight/ObjHeight; 

     var wRatio = PgeWidth/ObjWidth; 

     var zoomRatio = Math.min(hRatio, wRatio); 

     app.select(theObj); // to make active the page that holds theObj 

     myWindow.zoom(ZoomOptions.fitPage); 

     myWindow.zoomPercentage = myWindow.zoomPercentage; // * zoomRatio; 

    } 

     

     

    //See here for reference : 

    //https://forums.adobe.com/thread/2203330 

    function SetClipboard(clip){   

        var clipboard;   

        if(File.fs == "Macintosh"){   

            app.doScript ('tell application "Finder" to set the clipboard to "'+clip+'"',ScriptLanguage.APPLESCRIPT_LANGUAGE);   

        } else {   

           app.doScript ( 'Dim theObject\r Set theObject = CreateObject (\"htmlfile\")\r Call theObject.ParentWindow.ClipboardData.SetData(\"text\",\"'+clip+'\")', ScriptLanguage.visualBasic );  

        }   

        return;   

    }   

    

    main(); 

Here is what I could manage to change and run succefully:

  • Added colums to the linklist/data, which hold the page of the image (catching ' MF' if aside)
  • Googled a sort-by-key function for the links-array
  • managed to get a progress-bar to work, pointing to 100% if no image of matches the string-constants (= part of filepath), 100% work done. The 6/11 is CurrentMatches / Linklist.length
  • The Über = About window, will change into 'how-to'. Ill prepare an about-screen…should be no problem

Bildschirmfoto 2018-06-19 um 14.24.40.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines