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

when did words.length change? or what makes a word?

Enthusiast ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

some of my old scripts broke, don't know when it happened, but basically "This.Was.Four.Words" that text object used to be 4 words and now it is considered 1. the period no longer defines words? but…

 

when you introduce a number like this, "This.Is.3.Words", then the period matters. "This.Is" is 1 word, "3" is another, and finally "Words" is another

 

i don't see the logic to this. does anyone know why this changed and how is it beneficial?

TOPICS
Scripting

Views

1.1K

Translate

Translate

Report

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 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

Sorry, but your description is incomprehensible. Please explain in more detail what your script does.

 

  1. What is before in your document?
  2. What is after in your document?
  3. What happens (or doesn't happen) since your script is "broken".
  4. How well do you know scripting?
  5. How many lines of code does your script have?
  6. Can you post the relevant part of the code as plain text?

Votes

Translate

Translate

Report

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 ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

i don't see how any of that is relevant, my script is over 2000 lines. i've been doing this for a while, i have succesful extensions for sale on the marketplace.

 

simplified question 

for textFrames[index].words, what consituted a "word" has changed. i was using the Words collections as a means to verify formats for internal code numbers (like "I.WF05f.07.AB.000") and changing/updating different parts of number, like counting, formatting, exporting related data etc.

 

before a textFrame with contents of "I.WF05f.07.AB.000" would have a word count of 5, but now it has a word coutn of 4. code like textFrame[index].words[4].contents = "001", is now out of range. 

 

but anyway, i know why my script doesn't work, i'm asking when did this change, what illustrator version do i need to revert to?

 

extra if anyone knows of a white paper on what is a word in a word collection because "I.WF05f.07.AB.000" and "I.WF05f.AB.07.000" have different word counts. so far what i gather is that a period doesn't create words, but a period between 1 letter and 1 number does. seems like a complicated algorythm with no benefit. 

Votes

Translate

Translate

Report

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 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

Ich antworte lieber in meiner Muttersprache. So fällt es mir leichter, eine adäquate unmissverständliche Antwort zu schreiben. Wir sind nur Benutzer wie du auch. Und wir wollen dir bei deinem aufgetretenen Problem helfen.

 

Ob bzw. wann etwas an der Kollektion "Wörter" geändert wurde … das weiß ich leider nicht.

 

Dennoch gibt es sicherlich eine Lösung für dein Problem.

Alle meine Fragen waren berechtigt.

Da ich deine Frage nicht verstanden habe, musste ich zuerst wissen, ob du Kenntnisse hast - oder nicht.

Ohne deinen Code zu sehen, weiß ich nicht was dein Code machen soll. Die Frage nach der Länge deines Scripts hatte nur eine Relevanz: Ein paar Dutzend Zeilen Code kann man problemlos im Forum posten und wir können sie auch problemlos testen. Bei mehreren Hundert Zeilen Code geht das über den Rahmen des Forums hinaus.

 

Dann bleiben noch die Fragen nach dem:

Was war vorher in deinem Dokument? und

Was ist hinterher in deinem Dokument? und

Was passiert (oder passiert nicht mehr) seitdem dein Script nicht mehr funktioniert?

 

Du suchst nach einer Lösung. Alle diese Fragen würden zur Lösungfindung beitragen.

 

So wie ich das sehe, hast du bisher die Kollektion "Wörter" für einen Zweck "missbraucht", für den sie nicht gedacht ist. Das hat wohl bisher funktioniert. Jetzt scheint es nicht mehr zu funktionieren. Habe ich dich soweit richtig verstanden?

 

Wenn ja, dann gibt es wahrscheinlich nur zwei Möglichkeiten:

1) Zurück zur Version 26 (dort scheint es noch zu funktionieren) oder

2) die wahrscheinlich besser geeigneteren Codevarianten zu verwenden:

 - Arbeiten mit Arrays aus deinem String oder

 - Anwenden von Regex auf deinen String

 

Für diese Varianten muss man aber genau wissen, was mit deinem Inhalt/String genau passieren soll.

z.B. erhältst du auf diesem Weg genau das erwünschte Ergebnis

Textframe [0] mit Inhalt: I.WF05f.AB.07.000

 

var Arr = app.activeDocument.textFrames[0].contents.split(".")
alert(Arr.length)

 

Ergebnis: 5

Votes

Translate

Translate

Report

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 ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

i don't understand german. 

i also understand how to manipulate strings. strings are also formatted tho, for example in my numbers before "I.WF05f.AB.07.000", "WF05f" would be bold and the rest italic. or a different segment might get a different color. the Word collection allowe me to change the contents of 1 word without changing its format. in the example before you can do text.words[1].contents = "WF06b" and keeps it's appearance. 

 

but again. i can fix it. i'm wondering about the change.

Votes

Translate

Translate

Report

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 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

1) The forum has a translate function.
😉

2) Maybe the question would be better on Illustrator uservoice then? (Until your reply, I thought you needed help with the solution.)

 

And last but not least: I.WF05f.AB.07.000 is neither a word nor a collection of words.

Votes

Translate

Translate

Report

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 ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

when i say words, i don't mean language. in illustrators Object Model textframes have collections of Words, Lines, Characters, Stories, Etc. 

 

I.WF05f.AB.07.000 used to be 5 words in the OM

now it is 2 words. not my definitation

Votes

Translate

Translate

Report

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 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

Hi @mecdos 

I have understood that in the meantime. But no one here in the forum can do anything about it. The only remedy at the moment is to downgrade to v26 or post on Illustrator Uservoice.

(Even though my English is usually reasonably sufficient for the forum - I don't speak it fluently and for philosophical argumentation talks about things I can't change it is unfortunately absolutely not sufficient).

Sorry

Votes

Translate

Translate

Report

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 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

I don't have any answers, but for the sake of testing different versions/platforms of Illustrator I propose using this as a starting point:

// testing Illustrator's word division algorithm
(function () {

    var lines = [
        "This.Was.Four.Words",
        "This.Is.3.Words",
        "I.WF05f.07.AB.000",
        "I.WF05f.AB.07.000",

        // add more lines here if you want,
        // but don't change those above

    ],

        doc = app.activeDocument,
        tf = doc.textFrames.add(),
        results = '';

    tf.contents = lines.join('\n');

    for (var i = 0; i < lines.length; i++)
        results += '"' + lines[i] + '"  word count:' + tf.lines[i].words.length + '\n';

    alert('Results:\n' + results);

})();

 

Can anyone using older versions of Illustrator try the above script and share results? @femkeblanco?

 

Here's what I get on AI 27.4 MacOS 13.3.1:

"This.Was.Four.Words"  word count:1
"This.Is.3.Words"      word count:3
"I.WF05f.07.AB.000"    word count:4
"I.WF05f.AB.07.000"    word count:2

- Mark

Votes

Translate

Translate

Report

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 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

Irrelevent side note: Indesign gives these results:

"This.Was.Four.Words"  word count:1
"This.Is.3.Words"      word count:1
"I.WF05f.07.AB.000"    word count:1
"I.WF05f.AB.07.000"    word count:1
"This is four words."  word count:4

Votes

Translate

Translate

Report

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
Guide ,
Apr 13, 2023 Apr 13, 2023

Copy link to clipboard

Copied

Sorry for the late reply.  I get the same result as Monika in CS6 on Windows. 

femkeblanco_0-1681404162379.png

I've never thought about the definition of a "word" in AI, although I would have assumed it would be bound by whitespace. 

Votes

Translate

Translate

Report

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 12, 2023 Apr 12, 2023

Copy link to clipboard

Copied

CC2017

Bildschirmfoto 2023-04-12 um 11.04.00.png

 

CS6

Bildschirmfoto 2023-04-12 um 11.04.42.png

 

Both on MasOS 10.10.5

 

2021 and 2022 on MacOS 12.6.3 give the same results.

Votes

Translate

Translate

Report

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 13, 2023 Apr 13, 2023

Copy link to clipboard

Copied

I have posted a bug report. Please vote on it. It appears this problem may have been introduced while fixing another bug.

- Mark

Votes

Translate

Translate

Report

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 13, 2023 Apr 13, 2023

Copy link to clipboard

Copied

LATEST

Windows 11

 

Results: 2023 v27.3.1
"This.Was.Four.Words"  word count:1
"This.Is.3.Words"  word count:3
"I.WF05f.07.AB.000"  word count:4
"I.WF05f.AB.07.000"  word count:2

Results: 2022 v26.4.1
"This.Was.Four.Words"  word count:4
"This.Is.3.Words"  word count:4
"I.WF05f.07.AB.000"  word count:5
"I.WF05f.AB.07.000"  word count:5

Results: 2021 v25.3.1
"This.Was.Four.Words"  word count:4
"This.Is.3.Words"  word count:4
"I.WF05f.07.AB.000"  word count:5
"I.WF05f.AB.07.000"  word count:5

 

Votes

Translate

Translate

Report

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