Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
f = new File ('~/coordinates.txt');
f.open ('w');
g = app.activeDocument.allGraphics;
for (i = 0; i < g.length; i++)
{
data = File (g.itemLink.filePath).name + '\t';
data += g.itemLink.parent.absoluteHorizontalScale + ',';
data += g.itemLink.parent.absoluteVerticalScale + '\t';
data += g.itemLink.parent.parent.parent.name;
f.writeln (data)
}
f.close();
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
f = new File ('~/coordinates.txt');
f.open ('w');
g = app.activeDocument.allGraphics;
for (i = 0; i < g.length; i++)
{
data = File (g.itemLink.filePath).name + '\t';
data += g.itemLink.parent.absoluteHorizontalScale + ',';
data += g.itemLink.parent.absoluteVerticalScale + '\t';
data += FindWhere (g.itemLink).name;
f.writeln (data)
}
f.close();
function FindWhere (theObj,where)
{
var err;
if(where==undefined){where=Page}
if (theObj.hasOwnProperty("baseline"))
{
try{theObj = theObj.parentTextFrames[0];}
catch(err){}
}
while (theObj != undefined) {
var whatIsIt = theObj.constructor;
switch (whatIsIt) {
case where : return theObj;
case Note:
case Footnote: theObj = theObj.storyOffset;break;
case Character: theObj = theObj.parentTextFrames[0]; break;
case Cell: theObj = theObj.insertionPoints[0].parentTextFrames[0]; break;
case Application: return null;
}
if (theObj == undefined) return null;
theObj = theObj.parent;
}
return null;
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
var FindWhere = function (obj, where){
var kAppVersion = parseFloat(app.version);
var getTextContainer = function (s){
if(kAppVersion<5){return s.textFrames[-1]}else{return s.textContainers[s.textContainers.length-1]}
}
var getobj = function (fm){//returns the parent text frame, or the last one of the parent story
if(fm != undefined){return fm;}else{return getTextContainer(obj.parentStory);}
}
var getobj_ptf = function (obj){//get the parent text frame or return the original object (necessary for Notes)
try{ return obj.parentTextFrames[0]}catch(e){return obj}
}
var getobj_cell = function (fm){//returns the parent text frame, or the last one of the parnet story -- for cells
if(fm != undefined){return fm;}else{return getTextContainer(obj.insertionPoints[0].parentStory);}
}
var getnote_tf = function (note){//gets the note location for both footnotes and notes in all versions...
if(kAppVersion<5){
if(note.hasOwnProperty("footnoteTextFrame")){var parentFrame = note.footnoteTextFrame}//no good for overset...
else{var parentFrame = note.parentTextFrame}
if(parentFrame){return parentFrame}
else{return note.parent}
}
else{return note.storyOffset}
}
var e;
if(!obj){return null}
if(where == undefined){var where = Page;}
if(obj.hasOwnProperty("baseline")){obj = getobj(getobj_ptf (obj))}
while(obj){
switch(obj.constructor){
case where: return obj;
case Story: obj = getTextContainer(obj);break;
case Character: obj = getobj(getobj_ptf (obj));break;
case Cell: obj = getobj_cell(getobj_ptf(obj.insertionPoints[0]));break;
case Note:
case Footnote: obj = getnote_tf(obj);break;
case Application: return null;
}
if (!obj) return null;
obj = obj.parent;
}
return null;
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
#target indesign
myDoc = app.activeDocument;
myLink = myDoc.links[0];
myMessage = whereIsTheLink(myLink);
if (!isNaN(parseInt(myMessage))){
myMessage = 'page ' + myMessage;
}
alert("My link is on " + myMessage);
function whereIsTheLink(theLink){
while (theLink.constructor.name != 'Application') {
if (theLink instanceof Page) {
var myPageName = theLink.name;
return myPageName;
}
if (theLink instanceof Character) {
var thePage = whereIsTheLink(theLink.parentTextFrames[0]);
if (thePage != undefined) return thePage;
}
theLink = theLink.parent;
myHierarchy += theLink.constructor.name + '|';
}
if (myHierarchy.lastIndexOf('|Page|MasterSpread|Document|Application|') != -1)
{
return 'master page';
}
else if (myHierarchy.lastIndexOf('|MasterSpread|Document|Application|') != -1)
{
return 'pasteboard of master page';
}
else if (myHierarchy.lastIndexOf('|Spread|Document|Application|') != -1)
{
return 'pasteboard';
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now