Python expression to get point number inside Point SOP

I’d like to assign to each point on a line SOP a color by sampling a texture and use this point’s number for sampling. Is there a way to reference point’s number inside parameters of the Point SOP? I see InputPoint Class - Derivative does not have number member. Thank you!

The point’s number is available as its index. On a point SOP, for example, you could get to the index with:

me.inputPoint.index

Which you could then in turn use for sampling from TOPs or CHOPs.

Another pipline here is to use the CHOP to SOP and assign attributes from CHOPs.

2 Likes

it worked :slight_smile: Thank you Matthew!

1 Like

Hi Matthew!
What will this expression look like if i use scriptSOP.
If I need to select individual points on the surface, then translate them.

Great question @J21A - the script SOP generally requires that you loop through your points to make changes. So for your input geometry you’d loop through your points and then make changes.

Can you say a little more about what you’re trying to do? You have a lot of precise control in Python for making changes to your geometry, but it’s not the most efficient approach - and can require a lot of additional code. There might be some ways to get to what you’re after by using operators rather than just python.

1 Like

Hi Matthew,
many thanks for reply.

Star-shape with beams, I need to place many surface options for this shape, and I need a different length for each beam. I can’t figure out if it’s possible to control the length of individual beams in a single transform node(in picture), I would appreciate it if you could suggest a solution to my project.
It was decided to make it the code to optimize the performance of the minicomputer in the next project.
This model will have to be saved and printed on a 3D printer. I have a deadline tomorrow.
Thanks!

I’d consider using a Copy SOP and a Merge SOP to get the effect you’re after. This is how you can copy from another sphere, but you could also use another SOP to place those cones exactly where you want them.

spikes-toe.toe (4.1 KB)

1 Like

Thanks a lot! Nice and even shape, with fractal node result is amazing. Now i will create separate length parameters for cones.