Hi! I'm wodering if anyone has experience with the following or has some advice on how to approach it.
I need to display text from a CSV file on a set of cards that are laid out in a grid. I'm currently copying a font sop to the points of a grid in a foreach loop and using this expression in the font sops's text field:
`points("../foreach_begin1/", detail(-1, "iteration", 0), "name")`
My problem is that some of the strings are quite long so I'll need to format them into paragraphs. Is there a way to set up automatic line breaks when reading a string attribute while still respecting whole words?
Thanks for any help!
Cheers,
Chris
Formatting string attribute in Font SOP
1569 2 2-
- Charkin
- Member
- 2 posts
- Joined: Jan. 2016
- Offline
-
- toadstorm
- Member
- 406 posts
- Joined: April 2017
- Offline
Your best bet here would be to pre-format your text to include line breaks if the character length is too long. You could use the textwrap module in Python to process each paragraph to break it into wrapped lines.
Then bind the result to your attribute to be read into your Font SOP.
import textwrap test = "This is a very long string that I'd like to see split into reasonable lines or maybe I could hire a decent copy editor who would not write such stupidly long sentences." print(textwrap.fill(test, 40))
Then bind the result to your attribute to be read into your Font SOP.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
-
- Charkin
- Member
- 2 posts
- Joined: Jan. 2016
- Offline
-
- Quick Links

