Jump to content

Recommended Posts

Posted (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 by LaidlawFX
@ptnum haunts

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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;

 

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (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 by LaidlawFX
Found another link for declaring for future people.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×