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
[solved] expression used in Delete node doesn't work
6773 5 1-
- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
-
- graham
- 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
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
-
- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
-
- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
-
- graham
- 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.
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
-
- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
-
- Quick Links

