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

Script to create circle on correct alternative. Help?

Explorer ,
Dec 22, 2024 Dec 22, 2024

Can anyone help me create a script for InDesign? I've tried a few things, but I couldn't get everything to work properly or without causing errors.

How it should work: Objective: Create a circle over an item. This circle will represent the correct answer to the test questions I'm creating.

I select the text with itens (alternatives) and run the script. The script will ask me which answer is correct. I choose an answer (from 5 options), and it will create a circle over the selected item and anchor this circle right at the beginning of the text.

In the future, I'll apply a condition (Conditional Text) to this anchor, so I can hide the answer whenever I want.
Choolsing alternatives and run scriptChoolsing alternatives and run scriptexpand imageFinal resultFinal resultexpand image

TOPICS
Feature request , How to , Scripting
559
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

correct answers 2 Correct answers

LEGEND , Dec 22, 2024 Dec 22, 2024

@eusoujp

 

Maybe some clarification is needed - Object can be Anchored - or InLined. 

 

When Anchored - it can be physically located anywhere on the current spread - with an anchor in the selected place in the text. 

 

When InLined - it behaves like a letter / glyph - with limited shifting possibilities. 

 

So, if you Anchor your circle at the beginning of the correct answer - with desired shift from the anchor point - it will always be positioned in the same way. 

 

Translate
LEGEND , Dec 22, 2024 Dec 22, 2024

And, as you don't want answers to be always visible - you can modify applied ObjectStyle to shift those circles outside of the print area - outside of the page.  

 

Or simply remove stroke color / thickness - if it's just a circle. 

 

Translate
Community Expert ,
Dec 22, 2024 Dec 22, 2024

You should paste the script you've tried so we can potentially help you debug. Be specific about what doesn't work. No one is likely to rewrite it from scratch for free. 

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
Explorer ,
Dec 22, 2024 Dec 22, 2024

Yes of course. I was trying to create an object style so I could position it in the correct location, but it's a bit difficult to activate that option for me.

 

 

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
LEGEND ,
Dec 22, 2024 Dec 22, 2024

@eusoujp

 

There are two problems with your script: 

- it replaces text modifying contents - instead of working on the text as an Object,

- I'm pretty sure, you are using automatic numbering - so your letters a, b, c etc. are "virtual" and it won't find them,

 

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
Explorer ,
Dec 22, 2024 Dec 22, 2024

They are indeed converted into texts, not markers.
I’m using an application of a "tag" (<OBJ.ANCH>) to make it easier for findtext to locate this term and replace it with the object that has been cut to the clipboard using "^C". In other words, I create the circle, cut it to the clipboard (using cut()), insert the "tag" into the text, search for the tag, and replace the tag with the object. This way, I ensure that the object is being inserted into the line. Initially, I tried to create an object style to position the circle correctly, but I didn’t get good results.

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
LEGEND ,
Dec 22, 2024 Dec 22, 2024

@eusoujp

 

Wouldn't be quicker, to put cursor in the correct place - and just paste object copied to clipboard?

 

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
Explorer ,
Dec 22, 2024 Dec 22, 2024

Yes, that could be a solution. I’ve been thinking about the next steps, and I believe I’ll move toward something more robust. However, using the cursor to pinpoint the location might indeed be faster. Thanks for your answers — this has opened up new possibilities for me.

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
Explorer ,
Dec 22, 2024 Dec 22, 2024

I envisioned a future where I could perform a controlled action if I already knew the answers to several questions, and the script had already assembled everything in advance. Thanksss

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
LEGEND ,
Dec 22, 2024 Dec 22, 2024
quote

I envisioned a future where I could perform a controlled action if I already knew the answers to several questions, and the script had already assembled everything in advance. Thanksss


By eusoujp

 

Yeah, a lot can be automated. 

 

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
LEGEND ,
Dec 22, 2024 Dec 22, 2024

@eusoujp

 

That's why my first question was - if you know which answer is correct.

 

Because if you do - then you could apply dedicated ParaStyle to those answers - and then use F&C to anchor object from the clipboard. 

 

And even if you don't - applying dedicated ParaStyle first and then doing F&C to anchor - will be much quicker - as a workflow. 

 

You can even apply shortcut to the "correct answer" ParaStyle - and just use Ctrl+[down arrow] to jump between beginnings of the paragraphs and apply this style using shortcut. 

 

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
LEGEND ,
Dec 22, 2024 Dec 22, 2024

And, as you don't want answers to be always visible - you can modify applied ObjectStyle to shift those circles outside of the print area - outside of the page.  

 

Or simply remove stroke color / thickness - if it's just a circle. 

 

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
Explorer ,
Dec 22, 2024 Dec 22, 2024
Thank you, Robert. It helped me and clarified a lot of things.
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
LEGEND ,
Dec 22, 2024 Dec 22, 2024
LATEST
quote
Thank you, Robert. It helped me and clarified a lot of things.

By eusoujp

 

You're welcome. 

 

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
LEGEND ,
Dec 22, 2024 Dec 22, 2024

@eusoujp

 

Do you know in advance - when preparing your text - which answers are correct?

 

If you do - then you could create a dedicated Style for it - so no need for a script. 

 

And even if you don't know and need to decide "at the end" - you can still create a dedicated Style and just apply it to the correct answer - way quicker than selecting text, running script, selecting option and then confirming your choice. 

 

And if you need a special circle - then after applying dedicated Style - you could use F&C to add object, copied to the clipboard first, at the beginng of your correct answers - as an Anchored Object. 

 

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
Explorer ,
Dec 22, 2024 Dec 22, 2024

Ok, but I would still need to anchor the item text to the answer so that the position is always correct.

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
LEGEND ,
Dec 22, 2024 Dec 22, 2024
quote

Ok, but I would still need to anchor the item text to the answer so that the position is always correct.


By eusoujp

 

No, because if you set Anchoring position in applied ObjectStyle - it will automatically position itself correctly. 

 

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
LEGEND ,
Dec 22, 2024 Dec 22, 2024

@eusoujp

 

Maybe some clarification is needed - Object can be Anchored - or InLined. 

 

When Anchored - it can be physically located anywhere on the current spread - with an anchor in the selected place in the text. 

 

When InLined - it behaves like a letter / glyph - with limited shifting possibilities. 

 

So, if you Anchor your circle at the beginning of the correct answer - with desired shift from the anchor point - it will always be positioned in the same way. 

 

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
Explorer ,
Dec 22, 2024 Dec 22, 2024

Oh, yes, its true!

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