Copy link to clipboard
Copied
Given an insertion point, how can I determine if it contains an inline/anchored frame? And if so, how do I reference the inline/anchored frame?
I know how to reference the surrounding paragraph, characters, etc., but can't figure out how to get to the inline/anchored graphic.
I normally would just loop through all the inline graphics in the document, but it this case I need to access the inlines via their insertion points.
To reference the inline frame:
prevChar.pageItems[0]
or
nextChar.pageItems[0];
Copy link to clipboard
Copied
An insertion point does not contain anything.
It's always a character which contains an inline...
If you want to get the inline/anchored objects of text, use "text.pageItems" (or text.textFrames, etc.)
HTH,
Harbs
Copy link to clipboard
Copied
Harbs, I appreciate the guidance. I'm missing something here. If I have my cursor between two inline frames...
myDoc.selection[0] returns the insertion point,
But how do I reference the character on either side of the insertion point that contains the inline, and then once I have the character, how do I reference the inline frame?
Sorry I'm so dense!
Copy link to clipboard
Copied
var story = app.selection[0].parentStory;
var index = app.selection[0].index;
var prevChar = story.characters.item(index-1);
var nextChar = story.characters.item(index);
Copy link to clipboard
Copied
To reference the inline frame:
prevChar.pageItems[0]
or
nextChar.pageItems[0];
Copy link to clipboard
Copied
Or in one line:
//
alert(app.selection[0].parent.characters[app.selection[0].index].pageItems.length || app.selection[0].parent.characters[app.selection[0].index-1].pageItems.length);
//
![]()
--
Marijan (tomaxxi)
Copy link to clipboard
Copied
Thanks so much, Harbs. This is exactly what I needed to get me going. I learned something new today!
Copy link to clipboard
Copied
As far as I know, Insertion point can't hold inline/anchored object, but character does.
If you select text and run this line
alert(app.selection[0].pageItems.length);
it will return number of anchor/inline objects inside selected text.
Another way is to check parent of object. Parent of anchor/inline object is always character.
Example script that copies all anchor/inline objects to new layer: http://bit.ly/aV9WMF
Hope that helps.
--
Marijan (tomaxxi)
http://indisnip.wordpress.com/
http://inditip.wordpress.com/
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more