[solved] expression used in Delete node doesn't work

   6773   5   1
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
Hi, guys, I want to use express to delete the polygons of which the string attribute value is “N”. However, it doesn't work.

Can you kindly help to take a look and suggest a solution?

Thanks!

Ji
Edited by - Aug. 14, 2011 04:25:00

Attachments:
Capture.PNG (42.2 KB)
delet by expression1.hipnc (40.9 KB)

User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
The problem is that using == to test for string equality doesn't work so well. You should use strcmp() instead:
strcmp(prims(opinputpath(“.”, 0), $PR, “str”), “N”) == 0
You could also shorten your expression by just using the local variable:
strcmp($STR, “N”) == 0
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
hi, Graham, thanks a lot for your prompt help!
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
Hi, graham and other Houdinese,

May I ask how to do the same using Python script?

Thanks!
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
Python has proper string comparisons using == so you'd do something like this:
hou.pwd().curPrim().attribValue(“str”) == “N”
In many cases you could bypass that long bit of code by using lvar(“STR”) on the left hand side, however lvar only returns floats, so it is not useful in this case where your attribute is a string.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
Thank you very much for your advice, graham!
  • Quick Links