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!
VEX behavior
2987 2 1- david_aiken
- Member
- 86 posts
- Joined: Sept. 2008
- Offline
- john_z
- 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);
}
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);
}
- david_aiken
- Member
- 86 posts
- Joined: Sept. 2008
- Offline
-
- Quick Links