Word attribute from Font Sop

   1564   1   0
User Avatar
Member
12 posts
Joined: Jan. 2017
Offline
Hello everyone,

I'm trying to create a word attribute from the textindex attribute which you get from the font sop. The textindex attribute works like that:

Inputtext — "Hello World"
textindex attribute on each prim — 0, 1, 2, 3, 4, 6, 7, 8, 9, 10,

So after each Space there is a gap in the ascending arrangement of the values of the textindex attribute. Which technique do I have to use to get a word attribute out of it? The word attribute should be like this:

Inputtext — "Hello World"
textindex attribute on each prim — 0, 1, 2, 3, 4, 6, 7, 8, 9, 10,
word attribute — 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,

Best Regards,
Chrizzo

P.S.: Got it to work, thanks to Supermartin E.:

Put this into a detail wrangle and it works. Oh and you should sort the primitives of the font mesh by the textindex attribute before you do the wrangle.

int id = 0;
int id_old = 0;
int wordcounter = 0;

for(int i=0; i<@numprim; i++)
{
    id = prim(0,"textindex",i);
    
    if(id > id_old + 1) 
    wordcounter++;
    
    setprimattrib(0,"word",i,wordcounter);
    
    id_old = id; 
}
Edited by anon_user_46661527 - Feb. 20, 2020 14:33:13

Attachments:
Screenshot (33).png (60.8 KB)

User Avatar
Member
30 posts
Joined: May 2017
Offline
Haha, very happy to help Chris!

Just solved this issue some time ago and was a fun coding challenge. Thanks for documenting it.

Detail wrangles give you a hell of a lot of flexibility in comparing geometry with itself.

Cheers,
Martin
- Martin Egger
Student at Filmakademie BW
& Freelance FX TD
  • Quick Links