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

How to add contents in the anchor text?

Contributor ,
Jun 23, 2016 Jun 23, 2016

Hi experts,

My goal is add a tags in anchor text, here is orginal:

00001.jpg

here is my goal:

00002.jpg

Thanks

regard

John

TOPICS
Scripting
540
Translate
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 ,
Jun 23, 2016 Jun 23, 2016

So what did you try ?

Translate
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
Contributor ,
Jun 23, 2016 Jun 23, 2016

Hi Loic,

I got this script:

    app.findObjectPreferences = NothingEnum.nothing;

    app.changeObjectPreferences = NothingEnum.nothing;

    app.findObjectPreferences.anchoredPosition = AnchorPosition.ANCHORED;

var t  =myDocument.findObject();

    for(var i=0 ; i < t.length ; i++)

    {

            var tf=t;

            if(tf.parent.constructor instanceof Character)

            {       

              tf.texts.everyItem().move(LocationOptions.BEFORE, tf.parent);       

              tf.parent.contents = "</sn1>\r";       

            } 

        }

   

    app.findGrepPreferences =

    app.changeGrepPreferences = null

    app.findGrepPreferences.findWhat = "^(.+)</sn1>";

    app.changeGrepPreferences.changeTo = "<sn1>$1</sn1>";

    app.changeGrep();

for get anchor text into main story, and add tags

but How can I add the tags first will then get the anchor into main story?

thanks

Regard

John

Translate
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 ,
Jun 23, 2016 Jun 23, 2016

Well as far as I understand you should reach the insertionPoint you are interested in and add a textFrame to this object. Then you can add contents to the anchored text frame.

Translate
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 ,
Jun 25, 2016 Jun 25, 2016

Hi John,

did you analyze the script you are showing in answer #2 ?
Did you run it step by step, line by line, from the ESTK ( ExtendScript Toolkit )?
There is a step-by-step mode.

And you can set break points in the code and when a break point is reached you can inspect your variables in the JavaScript Console of the ESTK. Just write them into the Console window and press enter.

So you can find out what the variable tf really holds at that time.

Read the JavaScript Tools Guide for how to use the ESTK..
You can find that under "Help" in the ESTK.

Regards,
Uwe

Translate
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
Contributor ,
Jun 23, 2016 Jun 23, 2016

Thank you Loic

but How can I get insertPoint in each ANCHORD text frame?

Regard

John

Translate
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 ,
Jun 23, 2016 Jun 23, 2016

well insertionPoint is a child of the collection of insertionPoints that belongs to the textframe reference.

So that would be tf.insertionPoints[0];

Translate
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
Contributor ,
Jun 23, 2016 Jun 23, 2016

Hi Loic

I change it like this:

    app.findObjectPreferences = NothingEnum.nothing;  

    app.changeObjectPreferences = NothingEnum.nothing;  

    app.findObjectPreferences.anchoredPosition = AnchorPosition.ANCHORED;  

    var t  =myDocument.findObject();  

    for(var i=0 ; i < t.length ; i++)  

    {  

            var tf=t;

                tf.insertionPoints[0].contents = "<sn1>";          

              tf.insertionPoints[-1].contents = "</sn1>";

            if(tf.parent.constructor instanceof Character)  

            {          

              tf.texts.everyItem().move(LocationOptions.BEFORE, tf.parent);          

              tf.parent.contents = "\r";

            }    

        } 

but error.

Coule you please show me how?

Regard

John

Translate
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
Enthusiast ,
Jun 24, 2016 Jun 24, 2016

John or whatever your real name is:

First, a lot of topics this week. Second, those posts are realy annoying!

So, if you have a real problem, provide idml-files before/after. What should we do with your scrumbled screenshots? You know, I told you that from time to time.

If you provide code, this code should be runable. In your example 'myDocumet' is not declared.

Your code assumes, that you want to move everything from your anchored textframe in the normal textflow, but that is not what the second screen shows.

So:

1. Provide examples

2. Make a detailed list with steps, that must be scripted

3. Think about it and show your executable script trial

Kai

Translate
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
Contributor ,
Jun 25, 2016 Jun 25, 2016
LATEST

thank you Uwe,

I will try.

thank you so much.

regard

John

Translate
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