VEX behavior

   2802   2   1
User Avatar
Member
86 posts
Joined: Sept. 2008
Offline
hi all..

This VEX code stashes the point number in a string point attribute using Houdini 11.0.504:

sop
vexeg(
string pcloud_texture = “op:`opinputpath('.',0)`”;
float maxdist = 100.0;
int maxpnts = 10;
)
{
int src_number = ptnum;
int handle = pcopen(pcloud_texture, “P”, P, maxdist, (int)maxpnts);
string tst_str = “”;
while (pciterate(handle) )
{
tst_str = tst_str + sprintf(“%d;”, src_number);
}
addattribute(“tst”, tst_str);
}

The resulting “tst” attribute value is as follows:
Node tst
0 0;0;0;0;0;0;0;0;0;0;
1 0;1;1;1;1;1;1;1;1;1;1;
2 0;2;2;2;2;2;2;2;2;2;2;

So somehow i'm getting an extra entry after point 0. The compile reports success. Is there something wrong with the code? It seems tst_str is not getting initialised to “” for each node.

thanks!

Attachments:
vex_test.hipnc (25.9 KB)

I installed a skylight in my apartment… the people who live above me are furious!
- Steven Wright
User Avatar
Member
45 posts
Joined: June 2009
Offline
Hi,

the problem seems to be related to the sprintf evaluation with the ‘+’ operator.
I've tried the following code and it seems to work fine.


sop vexeg( string pcloud_texture = “op:`opinputpath('.',0)`”;
float maxdist = 100.0; int maxpnts = 10; )

{
int src_number = ptnum;
int handle = pcopen(pcloud_texture, “P”, P, maxdist, (int)maxpnts);
string tst_str = “”;
string tmp;

while (pciterate(handle) )
{
tmp = sprintf(“%d;”, src_number);
tst_str = tst_str + tmp;
}
addattribute(“tst”, tst_str);
}

sop vexeg( string pcloud_texture = “op:`opinputpath('.',0)`”;
float maxdist = 100.0; int maxpnts = 10; )

{
int src_number = ptnum;
int handle = pcopen(pcloud_texture, “P”, P, maxdist, (int)maxpnts);
string tst_str = “”;

while (pciterate(handle) )
{
tst_str = concat( tst_str, sprintf(“%d;”, src_number) );
}
addattribute(“tst”, tst_str);
}
User Avatar
Member
86 posts
Joined: Sept. 2008
Offline
Thanks.. it seems to be reproducible, then. Reported it as a bug.
I installed a skylight in my apartment… the people who live above me are furious!
- Steven Wright
  • Quick Links