Copy link to clipboard
Copied
object.LinkedPageItemOption.parent does *not* get the linked object, it is just the object.
How do I get the linked object!?
If object-A is a link of Object-B, how do I get object-B if i have object-A?
<Title renamed by MOD>
Copy link to clipboard
Copied
It returns the linked item not the source:
var sel = app.selection[0]
alert("LinkedPageOptions parent ID: " + sel.linkedPageItemOptions.parent.id + " Selection ID: " + sel.id)
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Unfortunately, this changes current selection...
We have a reference to the selection, so reselect. A function might be something like this:
var doc = app.activeDocument;
var sel = doc.selection[0];
$.writeln(getLinkSource(doc,sel))
//returns the source object
var source = getLinkSource(doc,sel)
source.fillColor= "Black";
app.activeDocument.links.everyItem().update();
/**
* Get a selected linked page item’s source
* @ param d, the document
* @ param sel a linked selection
* @ return the link’s source object,
* undefined if there is no selection or source
*
*/
function getLinkSource(d,sel){
var lnks = d.links.everyItem().getElements();
var src;
for (var i = 0; i < lnks.length; i++){
try {
if (sel.id == lnks[i].parent.id) {
lnks[i].goToSource();
src=app.selection[0];
app.select(sel)
}
}catch(e) {}
}
return src;
}
Copy link to clipboard
Copied