Create different 3D text on copy to points

   2398   3   1
User Avatar
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?

Attachments:
image.png (89.7 KB)
image1.png (16.7 KB)

User Avatar
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.
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")`
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.
Edited by Enivob - Dec. 23, 2022 11:06:48

Attachments:
Untitled-1.jpg (290.7 KB)
ap_point_drives_font_copy_122222.hiplc (556.2 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
144 posts
Joined: Aug. 2012
Offline
I've attached one way of doing something like this.

Attachments:
text_to_point.hiplc (127.8 KB)

User Avatar
Member
4 posts
Joined: Aug. 2021
Offline
Thank you so much to both of you. I tried both ways but Enivob's solution worked better for my project.
  • Quick Links