Skip to main content
February 25, 2020
Answered

Select parent of selected text

  • February 25, 2020
  • 3 replies
  • 1162 views

Hi All,

Im trying to select textframes indivudually and then bring up a dialog to see if the user wants to move the text parent to another layer. No problem for text frames but I can't get it to work for text on a path.

Any ideas of what I'm doing wrong?

Many Thanks, Bren

 

var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = ".*" // select text
var myFound = myDoc.findGrep(); for(obsty=0; obsty<myFound.length; obsty++)
{ myFound[obsty].parentTextFrames[0].select(), alert("Parent Selected")} // select parent

This topic has been closed for replies.
Correct answer Laubender

Hi Sunil,

my point is:

If parentTextFrames[0] is a text path, the parent of the text path is the object Bren likes to move to a different layer.

 

Case 1:

If that object is anchored, check if parent is a character, one cannot move it to a different layer until one unanchored the object.

Case 2:

If that object is part of a different nested structure like a group one could move it out of that nested structure first and then move it to a different layer.

 

One way to move it out of a nested structure is:

[1] Add a temp text frame to the spread where this object is.

[2] Anchor the object to the first insertion point of that temp text frame.

( That would move it out of a group or a different nested structure. )

[3] Release the anchored object.

 

Regards,
Uwe Laubender

( ACP )

3 replies

February 26, 2020

Hi guys,

Thanks for your responses, I understand the concern on the group/anchored subject and have got that covered in another part of my script so it's no problem 🙂

I need to be able to select any object in the document that contains text and be able to choose if I want to move it to another layer called "textblack", there maybe a different way to do this but my thoughts were to select text that is not on the "textblack" layer, then select its direct container and move that.

Is there a better way?

Thanks, Bren

Community Expert
February 26, 2020

Hi Bren,

you have to check what parentTextFrames[0] actually is.

If it is a text frame assign your layer to property itemLayer of the text frame.

If it is a text path assign your layer to parentTextFrames[0].parent.itemLayer.

 

Also see if your text has more than one parentTextFrames. This could be the case if your source text is running through several text containers of the story. Also think of the case that your text is in overset. Then there is no text container. Note that e.g. app.select() could also select text in overset. Or a GREP Find action could find text in overset.

 

Regards,
Uwe Laubender

( ACP )

LaubenderCommunity ExpertCorrect answer
Community Expert
February 26, 2020

Hi Sunil,

my point is:

If parentTextFrames[0] is a text path, the parent of the text path is the object Bren likes to move to a different layer.

 

Case 1:

If that object is anchored, check if parent is a character, one cannot move it to a different layer until one unanchored the object.

Case 2:

If that object is part of a different nested structure like a group one could move it out of that nested structure first and then move it to a different layer.

 

One way to move it out of a nested structure is:

[1] Add a temp text frame to the spread where this object is.

[2] Anchor the object to the first insertion point of that temp text frame.

( That would move it out of a group or a different nested structure. )

[3] Release the anchored object.

 

Regards,
Uwe Laubender

( ACP )

Community Expert
February 25, 2020

Hi Bren,

did you ask yourself what the parent of parentTextFrames[0] really is?

If app.selection[0].parentTextFrames[0] is [object TextPath], what is app.selection[0].parentTextFrames[0].parent ?

 

Regards,
Uwe Laubender

( ACP )

Sunil Yadav
Legend
February 26, 2020

If this parent text frame of text is part of a group or anchored into any other text frame then this text frame can not be moved to different layer.

On the other hand if it is placed on page or spread or any master page or spread then no worries.

 

Best

Sunil