chop() vex function

   2122   9   1
User Avatar
Member
211 posts
Joined: Nov. 2013
Offline
Using the hscript chop() command, I can pull the values from channels in my chopnet, eg to pull from the channel 'mydist0'
chop("../chopnet1/null1/mydist0")

Trying to do the same thing in vex and iterate over every channel (mydist0, mydist1, mydist2 etc) and it always returns 0.0.

string blah = itoa(@ptnum);
string thedist = "mydist" + blah;
float mychops = chop("../chopnet1/null1", thedist, @Frame)
f@testattr = mychops

I am not entirely sure what the 'Sample' argument should be as the docs aren't very clear. I assume this is what I'm messing up?
https://www.sidefx.com/docs/houdini/vex/functions/chop.html [www.sidefx.com]
Edited by Hamilton Meathouse - Oct. 6, 2021 00:40:28
User Avatar
Member
9380 posts
Joined: July 2007
Offline
I think you need to use op: syntax
float mychops = chop("op:../chopnet1/null1", thedist, sample);
Where sample is the fractional sample of your chop channel
So using @Frame instead may not be exactly the same, but can be close if your sampling rate is the same as fps, then it'll be just off by 1 as samples start from 0 and frames from 1
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
211 posts
Joined: Nov. 2013
Offline
Thanks Tamte - where/how would I find the sampling rate that my chopnet is using?

EDIT: Found it - Samples/sec is MMB click info. So in this case I would use @Frame/24 ?
Edited by Hamilton Meathouse - Oct. 6, 2021 02:28:04
User Avatar
Member
9380 posts
Joined: July 2007
Offline
Hamilton Meathouse
EDIT: Found it - Samples/sec is MMB click info. So in this case I would use @Frame/24 ?
If your sampling rate is 24 samples/s and frame rate 24 fps, then you would just use @Frame-1
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
211 posts
Joined: Nov. 2013
Offline
Hmmm. @Frame-1 returns 0 no matter what frame I'm on.
@Frame/24 returns 67.31 on every single frame (which is weird, as the chop channel it is pulling from increases every frame. I'll need to try a simple repro to upload
User Avatar
Member
9380 posts
Joined: July 2007
Offline
did use the op: syntax as mentioned?
as that was the main reason of it not working, the @Frame vs @Frame -1 was just a tiny technicality to point out that frames and samples in chops are not the same

here is a simple file

Attachments:
vex_chan.hip (91.1 KB)

Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
211 posts
Joined: Nov. 2013
Offline
Yep I have that correct - but as I said, using @Frame-1 or @Frame returns a constant value of 0 across all frames. If I use @Frame/24, I get a constant value of 66.86 across all frames
User Avatar
Member
9380 posts
Joined: July 2007
Offline
Hamilton Meathouse
Yep I have that correct - but as I said, using @Frame-1 or @Frame returns a constant value of 0 across all frames. If I use @Frame/24, I get a constant value of 66.86 across all frames
you may need to post a simple file then

did the file I posted work for you or do you see the same issue?
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
211 posts
Joined: Nov. 2013
Offline
Ok, works fine in sops, but doing it inside a point instancer in LOPs it does not seem to like.
User Avatar
Staff
445 posts
Joined: Feb. 2008
Offline
Does it work if you use a full path to the chopnet rather than a relative path?
  • Quick Links