Create different 3D text on copy to points
2397 3 1- Mihaela12
- Member
- 4 posts
- Joined: Aug. 2021
- Offline
Hello everyone,
I am very new to python and Houdini in general but I am having some troubles.
I want to create different text for each point using python.
Since I am using copy to points I created a counter for the points in order to differentiate them. I have named them picNum and the points are animated to spawn one or a few at a time through a number of frames. Now I am trying to have different 3D text from the font sop to appear on each point. Currently I am saying that picNum = geo.points() because it doesn't recognize the name picNum unless I define it again. But then it takes every point in the node system instead of only the picNum numbering.
How can I code it to follow the number of the picNum attribute?
I am very new to python and Houdini in general but I am having some troubles.
I want to create different text for each point using python.
Since I am using copy to points I created a counter for the points in order to differentiate them. I have named them picNum and the points are animated to spawn one or a few at a time through a number of frames. Now I am trying to have different 3D text from the font sop to appear on each point. Currently I am saying that picNum = geo.points() because it doesn't recognize the name picNum unless I define it again. But then it takes every point in the node system instead of only the picNum numbering.
How can I code it to follow the number of the picNum attribute?
- Enivob
- Member
- 2625 posts
- Joined: June 2008
- Offline
You can loop a CopyToPoints node. It may seem silly, because each iteration of the CopyToPoints runs only over one value, point #0 presented by the loop. You can use this to your advantage, however, "hard-coding" a reference to the attributes available to point #0. Each iteration through the loop will present a new string value you can supply to the font node.
It simplifies the wrangle code set up. No Python fixup after generation is needed.
The hScript expression on the Font node accessing the string value for the copy looks like this. Whatever the value of the current point attributes at the top of the loop (i.e. foreach_begin1) gets installed into the font copy per iteration.
NOTE: The "s" part of the points function. That denotes you are fetching a string value from the attribute named. The companion hScript function point only fetches numbers.
It simplifies the wrangle code set up. No Python fixup after generation is needed.
s@phrase = "A"; if(@ptnum==1){s@phrase = "B";} if(@ptnum==2){s@phrase = "M";} if(@ptnum==3){s@phrase = "Z";} if(@ptnum==4){s@phrase = "Q";} if(@ptnum==5){s@phrase = "S";}
The hScript expression on the Font node accessing the string value for the copy looks like this. Whatever the value of the current point attributes at the top of the loop (i.e. foreach_begin1) gets installed into the font copy per iteration.
`points("../foreach_begin1",0,"phrase")`
Edited by Enivob - Dec. 23, 2022 11:06:48
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- Jikian
- Member
- 144 posts
- Joined: Aug. 2012
- Offline
- Mihaela12
- Member
- 4 posts
- Joined: Aug. 2021
- Offline
-
- Quick Links