Certain VEX code makes C4D HDA fail

   492   2   1
User Avatar
Member
2 posts
Joined: Oct. 2015
Offline
Hi everyone.

I'm having some trouble getting an HDA to open properly in C4D. The setups I'm developing use quite a bit of VEX code and I've noticed that certain functions etc seem to break assets. I've simplified this example as much as possible and I can detect the line of code which breaks everything.

The setup is as follows:

Sphere (Set to polygon mode)
|
Attribute Wrangle

That's all. At this stage, the sphere happily imports to C4D with the green HDA icon.

I can add this line of code and all is well too :
vector p = @P;

However, if I add this line (which does exactly the same thing) it no longer works:
vector p = pointattrib(geoself(),"P",@ptnum,0);

I'd love to know if anyone has any insights into why this may be the case.

Thanks,

Adam
pixelsinprogress.com
User Avatar
Staff
1450 posts
Joined: March 2012
Offline
The second piece of VEX code probably isn't compiling. pointattribis the function to use if you want to receive an indication of whether the lookup was successful or not; the last argument is a reference to an int variable, e.g.:

int success;
vector p = pointattrib(0,"P",@ptnum,success);

If you don't need an indication of whether the lookup succeeded, you can use point:

vector p = point(0,"P",@ptnum);
(Edit: I forgot to delete the “int success;” when I first posted this second version.)

Note that in this specific case, given hat you're only looking up the value at @ptnum, using @Pwill probably be much faster.

Also note that, although geoself()currently just returns 0, it's intended to indicate the output in functions that write to the output, whereas the first argument to any VEX function reading from geometry is either the input number to read from (in this case, input 0), or a string indicating the file path (or node path if it begins with op:). That wouldn't affect whether it compiles though, that's just a semantic note.

Hopefully that helps clarify things!
Edited by ndickson - July 11, 2017 12:45:21
User Avatar
Member
2 posts
Joined: Oct. 2015
Offline
That was exactly what I was looking for. Thanks!

I had no idea that a declared variable HAD to be passed to the function. Houdini itself does not kick up a fuss if you just throw a 0 in there so I foolishly assumed that it would not matter for compiling/exporting an HDA.

I can confirm that both instances which you describe above work perfectly well when importing them into C4D. I had completely missed the point() function for some reason.

Finally, yes I did know about the geoself() business, I more often than not just use 0 as the input as it is shorter but as I was all officially posting in the forums, I thought I'd use what I assumed was the correct function

Thanks again,

Adam
pixelsinprogress.com
  • Quick Links