Breaking text into letters - the case of "!"

   2020   0   1
User Avatar
Member
130 posts
Joined: April 2009
Offline
Hello,

I have stumbled today upon an issue gently “hidden” in the very first video tutorial listed in houdini help (ui_intro.mov). The tutorial shows how to break a text into letters, and then do some RBD stuff. I'd like to dig deeper into the first part: breaking the text. Here is the setup:

txt = hou.node('/obj').createNode('geo',run_init_scripts=False)
fon = txt.createNode('font')
fon.parm('text').set('012345')
con = txt.createNode(“connectivity”)
con.setFirstInput(fon)
con.moveToGoodPosition()
par = txt.createNode('partition')
par.setFirstInput(con)
par.moveToGoodPosition()
par.parm('rule').set('letter_$CLASS')
xf = txt.createNode('xform')
xf.setFirstInput(par)
xf.moveToGoodPosition()
xf.setDisplayFlag(True)
xf.setRenderFlag(True)
xf.parm('tz').set(-1)

#the following results in characters “3” and “4” being transformed
xf.parm('group').set('letter_0 letter_4')

So far so good. Two questions:
- how to deal with multi-part letters, like “i” or “!”? They are broken into separate objects by the above network
- how (if possible at all) to force the groups to be created in the order of the individual letters? so that letter_0 is always the first character?

I assume the above is doable with a bit more python scripting, by splitting the text into individual letters fist, and converting each letter into a group, but maybe there is a shortcut way - some way to set up the nodes in such a way that the connectivity will recognize the letters, rather than shapes?

Thanks for any hints,
Greg
  • Quick Links