Indexing point attribute. Help needed

   4560   9   1
User Avatar
Member
20 posts
Joined: 10月 2009
Offline
Back here because of my previous topic.
Thank you guys who helped me before.
So I have 2 points created by the Add surface node.
Then I added an attribute ‘attribute1’ to each point by the Attrib Create surface node.
The ‘attribute1’ attrib has a class of ‘point’, type of ‘integer’,size of 1 and the ‘Value’ parameter equal to $PT (or lvar('PT') for python).
Another words the point#0 has the attribute1 = 0, and point#1 attribute1 = 1.
Then I subsequently added the Transform surface node in which I want the ‘ty’ parameter to be equal to the ‘Value’ parameter of the ‘attribute1 for point#1 ,i.e 1.
What I dug out from the help on HOM should look like the sequence

1. a = hou.node(’/obj/geo1/xform1')
2. g = a.geometry()
3. i = g.iterPoints() (where … stands for point #1)
4. x = i.attribValue('attribute1')

and voila you have x = 1 and put it into the ‘ty’ parameter!
That's okay but it only worked in the Python shell. I can't figure out what kind of expression I have to type in the ‘ty’
parameter field which resides inside the Transform surface node. Whatever I tried nothing worked yet
Please help cos I am new to HOM and expressions
User Avatar
Member
1921 posts
Joined: 11月 2006
Online
You are just trying to do it inside the TY parm of a Transform SOP? If that's the case all you need to do is use the local variable as the parm value. No python required.

If you want to do it with Python you can of course use lvar() for the local variable, or hou.pwd().curPoint().attribValue(“attribute1”)

If you wanted to do it within a Python SOP you could do
point_positions = list(geo.pointFloatAttribValues(“P”))
y_xforms = geo.pointFloatAttribValues(“attribute1”)

for i in range(len(y_xforms)):
point_positions

geo.setPointFloatAttribValues(“P”, point_positions)
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
20 posts
Joined: 10月 2009
Offline
This is what the Attrib Create surface node looks like


And the Transform surface node must look like



If you just use hou.pwd().curPoint().attribValue(“attribute1”)
it does'nt work because there is no point iteration. What I need is
to use direct access to the point#1 attribute1, 'some_expression',
which directly gives the integer value 1
User Avatar
Member
1921 posts
Joined: 11月 2006
Online
Sorry about that. The curPoint() stuff would be inside TY on a Point SOP. I'm not quite sure what it is you are after.

If you just want point 1's attribute value you can do hou.pwd().geometry().iterPoints().attribValue(“attribute1”)?
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
20 posts
Joined: 10月 2009
Offline
Still got an error ‘unable to evaluate expression’
User Avatar
Member
20 posts
Joined: 10月 2009
Offline
hou.pwd().geometry().iterPoints().attribValue('attribute1') is definitely
what works in the python shell but not inside parameter field as expected.
Is it a bug?
User Avatar
Member
1921 posts
Joined: 11月 2006
Online
My bad. I forgot to mention that you can't access the geometry of the current operator and modify it in the same node. You need to use the input node. The correct code is this.
hou.pwd().inputs()[0].geometry().iterPoints()[1].attribValue("attribute1")
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
321 posts
Joined: 7月 2005
Offline
graham
My bad. I forgot to mention that you can't access the geometry of the current operator and modify it in the same node. You need to use the input node. The correct code is this.
hou.pwd().inputs()[0].geometry().iterPoints()[1].attribValue("attribute1")[/quote]

Seems a bit excessive compared to just using $ATTRIB1 in the ty field. I'm not sure why we're in Python "mode" of thinking for this problem.

However, the original question implied using a transform SOP per point, which is not an option. The transform SOP operates on all of the geometry using the values in the parameter fields. It does not evaluate these fields per point. For that you need the point SOP.

Or how about point("../previousSOP", $PT, "attrib1", 0)
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
User Avatar
Member
20 posts
Joined: 10月 2009
Offline
It works! This is exactly what I need.
To Antoine Durr: It's just the way I learn Houdini and I'm trying to push it to the limits and see whether it can do what I want or cannot. Seems can.
Thank you guys!
User Avatar
Member
321 posts
Joined: 7月 2005
Offline
valshev
It works! This is exactly what I need.
To Antoine Durr: It's just the way I learn Houdini and I'm trying to push it to the limits and see whether it can do what I want or cannot. Seems can.
Thank you guys!
With the introduction of the closely integrated Python environment, I'm seeing a lot of folks looking for solutions in the HOM realm rather than with the tools already there. ‘exhelp’ and ‘help’ (in the textport) are your friends!
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
  • Quick Links