Copy link to clipboard
Copied
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 script
Final result
2 Correct answers
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.
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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,
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Wouldn't be quicker, to put cursor in the correct place - and just paste object copied to clipboard?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you, Robert. It helped me and clarified a lot of things.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Ok, but I would still need to anchor the item text to the answer so that the position is always correct.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Oh, yes, its true!

