Jump to content

Splitting words


rurik

Recommended Posts

Hello

I have a sentence of words, and I'm looking for a method that would allow me to control the words (not the letters) using a particle simulation.

My guess is that if I can somehow group the words and create an attribute that identifies each word (vs each letter, which would just be $PR), I would be in business.

However I am not sure how to go about that...

I have a result that I'm having a hard time controlling using a method where each word is painted a certain color, then the ForEach uses the Cd attribute to split the letters. But for some reason it seems to be giving me issues when I try to copy the words to my particle system...

Any suggestions would be most welcome

Thanks!

Alex

  • Like 1
Link to comment
Share on other sites

If you decide to use Python there are a plethora of awesome tools for working with strings. For example split() which will separate strings based on the argument like a space.


foo = 'This is my example sentence'
words = foo.split(' ')
for word in words:
print word
[/CODE]

That puts each word into a list and then prints them, the output looks like this.

[CODE]
This
is
my
example
sentence
[/CODE]

From there you just pull whatever one you want like with the index, like words[3] but the index could be an attribute from the particle. I don't have Houdini in front of me to try it out but I can send an example later if you want to try it with Python instead of Hscript expression.

Link to comment
Share on other sites

Hello Sadhu and Luke

Both those suggestions seem great. I'm not quite sure how I would create groups using arg though...I am actually using arg for a separate part of the project where I need to just need to feed an expression with a series of words that then get copy stamped.

However the Python option seems more powerful, and I am definitely interested in exploring the Python route..An example would be fantastic..

What my end goal is to be able to type in a sentence inside of an expression (or a field if I can make this an asset) and have that create a sentence that has each word in one group, or if not in a group, assigned to a custom attribute.

Hopefully that makes sense...

Thanks!

Alex

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...