This should be absurdly easy, but the normal functions don't seem to be working.
I'm using a delete node to try deleting all but the last couple of points in a line. The very first thing I need to do is retrieve the number of points there are, and I'm already stuck. Based on the tutorials I've gone over, and all the searching I've done online, I should be able to just type something like $NPT into the pattern, but it's saying this isn't an actual function. At least not one that works in this context. In fact, any particular letter only seems to have a couple options available. For example, $N can only be N, NEXT_OT or NFRAMES.
Is this all deprecated information I've been finding online? What would be the normal approach to retrieving this?
Retrieving number of points in a line
18011 10 1-
- Grimwolf
- Member
- 46 posts
- Joined: March 2016
- Offline
-
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
It seems to work with “Operation” (the top one) set to “Delete Non-Selected”, “Entity” set to “Points”, “Operation” (the bottom one) set to “Delete by Range”, “Start/End” set to
$N-1and $N, and “Select _ of _” set to 1 and 1. If you'd like to completely avoid local variables in expressions, you can use npoints(0)-2and npoints(0)-1as expressions in “Start/End”.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
-
- Grimwolf
- Member
- 46 posts
- Joined: March 2016
- Offline
-
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
The current frame number is usually
$F(for the integer part of the frame number only) or $FF(for the floating-point frame number). $Fand $FFare global variables, so don't depend on the SOP interpreting them in a particular way. Which doc page or other place says that of $N?$Nis a local variable returning the number of elements of the type determined by the SOP in question… minus one, (as described at the bottom of this page [www.sidefx.com]). It's rather unintuitive, (among a few other issues with local variables themselves), so using the HScript expression `npoints(0)-1` makes it a little clearer to a reader what's going on and how to find out more about what's going on.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
-
- Grimwolf
- Member
- 46 posts
- Joined: March 2016
- Offline
-
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
Ah, okay, that's under the “Render nodes” heading, so it applies to ROP nodes, things like the Mantra ROP or Geometry ROP, usually either in /out or in a ROP Network, (though you can also create a ROP Output Driver or ROP Alembic Output node in SOPs). I'm not 100% sure, but in that context,
$Nmight be the number of the frame relative to the sequence being rendered/output, as opposed to the absolute frame number, which is probably still $For $FF.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
-
- Grimwolf
- Member
- 46 posts
- Joined: March 2016
- Offline
ndicksonThe problem is though, it's only listed in there. As far as I could tell, the documentation gave me no reason to believe it did anything else.
Ah, okay, that's under the “Render nodes” heading, so it applies to ROP nodes, things like the Mantra ROP or Geometry ROP, usually either in /out or in a ROP Network, (though you can also create a ROP Output Driver or ROP Alembic Output node in SOPs). I'm not 100% sure, but in that context,$Nmight be the number of the frame relative to the sequence being rendered/output, as opposed to the absolute frame number, which is probably still$For$FF.
Do you know of a better source for the various Houdini expressions? I could really use one.
Edited by Grimwolf - July 17, 2017 17:41:47
-
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
Good point. Local variables are node-specific, so it's described on the doc page for the Delete SOP [www.sidefx.com], at the bottom. We've slowly been reducing their prevalence for various reasons, which is probably part of why there's only a little bit on local variables on the “Parameter expressions” page:
I tend to mostly be searching for expression functions when I'm looking for expressions help, so I use this page [www.sidefx.com], though that probably isn't as useful for getting information when first starting out. When I'm trying to learn how to use something I'm not yet familiar with, I usually look for examples to understand and adapt, so the Expression cookbook [www.sidefx.com] page might help; it has a bunch of examples. There are also probably a whole bunch of tutorials on HScript expressions out there, if you prefer to learn from tutorials, though I don't know which ones are good or bad at explaining or describing things.
Local variables. Nodes often provide variables that are useful for expressions on nodes of that type. For example, a node that operates over the points in a geometry will have a @ptnum variable representing the point number of the current point. The help for a node will list the local variables you can use in expressions on that type of node.
I tend to mostly be searching for expression functions when I'm looking for expressions help, so I use this page [www.sidefx.com], though that probably isn't as useful for getting information when first starting out. When I'm trying to learn how to use something I'm not yet familiar with, I usually look for examples to understand and adapt, so the Expression cookbook [www.sidefx.com] page might help; it has a bunch of examples. There are also probably a whole bunch of tutorials on HScript expressions out there, if you prefer to learn from tutorials, though I don't know which ones are good or bad at explaining or describing things.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
-
- Grimwolf
- Member
- 46 posts
- Joined: March 2016
- Offline
-
- Colby Winfield
- Member
- 8 posts
- Joined: Dec. 2013
- Offline
-
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
There's also the
@numptbuilt-in VEX variable that will automatically get the same value as npoints(0), so you can shorten it to:if (@ptnum < @numpt-2)
removepoint(0, @ptnum);
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
-
- Quick Links


