LaidlawFX Posted July 22, 2019 Share Posted July 22, 2019 (edited) Hello, So doing some clean up on my vex code in a wrangle and I turned on Enforce Prototypes to remove a bunch of the hacks to get the code setup. The one thing I can not find out a cleanup for is to replace @ptnum with a non @ function. Is the only way to declare it prior to the wrangle as another attribute? That just seems messy. Even declaring before hands means you need @ptnum to source that attribute. Thanks, -Ben Edited July 22, 2019 by LaidlawFX @ptnum haunts Quote Link to comment Share on other sites More sharing options...
Skybar Posted July 23, 2019 Share Posted July 23, 2019 Not sure if I understand you correctly but this works: https://github.com/jtomori/vex_tutorial#enforce-prototypes So with Enforce Prototypes turned on, basically: int @ptnum; vector @Cd; @Cd = @ptnum; Quote Link to comment Share on other sites More sharing options...
LaidlawFX Posted July 23, 2019 Author Share Posted July 23, 2019 Here is an example file of using @ptnum to source a point attribute that errors out when enforce Prototype is on. int id = point(0,"id",@ptnum); setpointattrib(0,"Cd", @ptnum,id); Upstream of that I have an attribute create that does a basic. i@id=@ptnum; ptnum.hip Quote Link to comment Share on other sites More sharing options...
Skybar Posted July 24, 2019 Share Posted July 24, 2019 11 hours ago, LaidlawFX said: Here is an example file of using @ptnum to source a point attribute that errors out when enforce Prototype is on. int id = point(0,"id",@ptnum); setpointattrib(0,"Cd", @ptnum,id); Upstream of that I have an attribute create that does a basic. i@id=@ptnum; ptnum.hip Yeah in that case you need to declare @ptnum at the top. So: int @ptnum; int id = point(0,"id",@ptnum); setpointattrib(0,"Cd", @ptnum,id); Think of it as a key. If you write @ptnum further down, it will take a look to see if it's allowed to accept that. If it isn't declared, or if you make a typo (@ptnmu) it will error because it isn't allowed. I don't think you can get rid of @ altogether, but you can add it to a variable to get rid of it further down: int @ptnum; int pointnum = @ptnum; 1 Quote Link to comment Share on other sites More sharing options...
LaidlawFX Posted July 24, 2019 Author Share Posted July 24, 2019 (edited) Thanks for that. I just re-read what you said and that link you sent. Had to do a double check and it follows the pattern in cvex, too. It's been a long time since I looked at vex like this. cvex obj_geo1_pointvop1(int ptnum = 0; export int Cd = 0) { // Code produced by: bind1 Cd = ptnum; } Thanks again. Found the declaring part in the docs again, too. https://www.sidefx.com/docs/houdini/vex/snippets.html#declare Edited July 24, 2019 by LaidlawFX Found another link for declaring for future people. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.