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

Need script that "unview" letters in text

Explorer ,
Apr 12, 2013 Apr 12, 2013

Hello. I need a script for Illustrator CS6, that...

1. Opens a dialog where I enter a letter, like "A".

2. Script then check the current layer for text with this letter, and "unview" (opacity = 0 or color=white), all other letters on this layer. So that the layer will only show "A", or "a" and no other type of letter. The script needs to check all text objects, some "a"s will be in objects consisting of several other letters also, like sentances. Script needs to find the letter in these and mute all others.

Would someone like to help me with this ? thank you.

DanielR
Posts: 25
Joined: Thu Mar 22, 2012 1:25 pm
TOPICS
Scripting
2.4K
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
Adobe
Community Expert ,
Apr 13, 2013 Apr 13, 2013

// CharacterColorizedIfNotMatchPrompt.jsx

// Hint: test the script with little text.

// The more extensive the text, the more time it takes the script.

// greetings pixxxel schubser

// http://forums.adobe.com/thread/1190610?tstart=0

var aDoc  = app.activeDocument;

var col = new CMYKColor();

col.cyan = 0;

col.magenta = 20;

col.yellow = 0;

col.black = 0;

var aTFrame = aDoc.textFrames;

if (aTFrame.length > 0) {

    var check = prompt ("Which character?", "a");

    check1 = check;

    check2 = check1.toUpperCase();

    for (i=0; i<aTFrame.length; i++) {

        for (j=0; j<aTFrame.characters.length; j++) {

            aChar = aTFrame.characters;

            if (aChar.contents != check1 && aChar.contents != check2) {

                aChar.fillColor = col;

                }

            }

        }

    }

alert("done")

Try this.

Have fun.

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 ,
Apr 14, 2013 Apr 14, 2013

FANTASTIC !!!! MAGNIFICENT !!! Works like a charm... two questions..

1. Does it also work in Indesign ?

2. Do you think it would be possible to add a function, were the script after changing color on letters, place a solid black circle in the centre on each of the characters now in view ? So if I choose "a", then all other characters get different color AND a black circle is placed over each "a" in the image, with each circle on it's own layer ?

I don't know if the position of the circles can be set exactly, as letters can be of different sizes. But it would be good enough to have the circles placed somewhere on to the letter.

Is this possible ?

Thanks for your magnificent help !!

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 ,
Apr 14, 2013 Apr 14, 2013

Also.. new script should ask if I want to ad circles on top of the letters. I can choose yes or no.

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 ,
Apr 14, 2013 Apr 14, 2013

You don't need a script for changing color in InDesign. Instead, use GREP.

Regarding the black circle - you can show me an example?

What purpose does it work?

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 ,
Apr 14, 2013 Apr 14, 2013

what is GREP ?

I'm a historic cryptographer. this script will speed up analysis.

I can't seem to be able to upload an example to you here. Can I email it to you, an image with dots on letters ?

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 ,
Apr 14, 2013 Apr 14, 2013

if

snookieface wrote:

what is GREP ? …

… I can't seem to be able to upload an example to you here …

GREP is the silver bullet for replacing text in InDesign.

Press Strg+F and go to the register GREP

For the upload: in reply-dialog you can use the "camera-button" for upload.

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 ,
Apr 14, 2013 Apr 14, 2013

example.jpg

now it worked.... thanks

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 ,
Apr 14, 2013 Apr 14, 2013

i would be satisfied with same size dots... but if it's easy to make diameter adapt to font size somehow, it would be good.

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 ,
Apr 14, 2013 Apr 14, 2013

A simple way in the UI (without script).

make a Copy of the text

create outlines of this textcopy

ungroup this group

(now in appearance palette)

give one character a new fill

give this fill the right color

give this fill the effect (convert to circle --> absolut) and set it to multiply

copy this appearance with eyedropper to the other

1235_37.png

You can save this appearance also as a graphic style.

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 ,
Apr 15, 2013 Apr 15, 2013

Thanks a bunch. Questions..

1. The final result I need is an illustrator doc with only black solid dots. I need to export to swf with dots on separate layers being converted to graphic symbols. So all letters must be gone before I export. I need swf to put in other swf script.

2. the method you gave above seem very good. But then I would need your first script to copy only the visible letters to a new layer also ? So that other letters are on one layer, and the visible have a copy on a separate layer ? Then I can make circles on the new layer with the method you gave.

3. But how do I remove the letters after I have created circles ?

thanks for all your help...

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 ,
Apr 15, 2013 Apr 15, 2013

This is doable.

Create a new Symbol with your circle. (manually)

Make a copy and convert to path with textFrames.duplicate() and createOutline()

Create a new layer. Search the items with same color like your text. Move() this items to the new layer and select all the compoundPathItems.

Hide and lock the other layers.

That is, what you should do.

Than you can use (instead using a graphic style) a script like JET's ReplaceWithSymbols.jsx

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 ,
Apr 15, 2013 Apr 15, 2013

Thanks very much.. but I'm not a coder, so I don't understand much. Is this what you mean...

1. Run your script, a letter is shown.

2. Create a symbol in Illustrator, a circle.

3. Copy the layer owith the text (both marked and unmarked text), and create outlines.

4. On the new layer, remove all text that is not marked.

5. Use script JET's Replacewithsymbol.jsx to put circles instead of the letters.

--------------------

Questions...

As I'm not a coder, but do you think it would be easy to change your script so that it deletes all text that is not the chosen letter on that layer ? Probably we need to make outlines first to get the marked letters in the same exact positions ?

After this I could easily use the JET script maybe ?

Thanks for all your help.

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 ,
Apr 16, 2013 Apr 16, 2013

Point 1 - 5 --> correct.

This is the same procedure, regardless of whether in UI or via script.

I think you will need the script for commercial use.

To finish the script, I'll need more time than I would like to invest. Maybe someone else takes time for you.

My English is not the best. I hope you understand me anyway right. Please do not be angry. It saves you already a relatively long time.

The Jet script has (for your project) a small "flaw". It aligns the lower left corner of the symbol to the lower left corner of the character. That should you have to also adapt yet.

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 ,
Apr 16, 2013 Apr 16, 2013

I thank you VERY much for your help.

It is not for commercial use. A hobby.

Ones again... thanks

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 ,
Apr 20, 2013 Apr 20, 2013
LATEST

snookieface wrote:

Hello. I need a script for Illustrator CS6, that...

1. Opens a dialog where I enter a letter, like "A".

2. … Script needs to find the letter in these and mute all others …

snookieface wrote:

FANTASTIC !!!! MAGNIFICENT !!! Works like a charm …

… Thanks for your magnificent help !!

In this case: Can you mark the correct answer as correct or helpful, please?

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