going through wrangle introduction tutorial and i'm new to vex/wrangle language.
i'm doing a very simple thing, a grid with random y value.
when i set “rand_y” variable it works fine.
v@rand_y = set(0, random(@ptnum), 0);
@P += @rand_y;
but when i wrote down everything in a line i got an error;
@P += {0, random(@ptnum), 0};
why is that?
hb
wrangle newbie
2011 3 0- garin2
- Member
- 37 posts
- Joined: Aug. 2012
- Offline
- TwinSnakes007
- Member
- 605 posts
- Joined: July 2013
- Offline
You cannot create vectors with {} brackets.
Vectors can only be created via ‘set’ method.
If your first example, the ‘set’ method is called and vector @rand_y is created which is then assigned to @P.
In your second example, you are trying to assign an undefined vector to @P.
Vectors can only be created via ‘set’ method.
If your first example, the ‘set’ method is called and vector @rand_y is created which is then assigned to @P.
In your second example, you are trying to assign an undefined vector to @P.
Houdini Indie
Karma/Redshift 3D
Karma/Redshift 3D
- garin2
- Member
- 37 posts
- Joined: Aug. 2012
- Offline
- mestela
- Member
- 1742 posts
- Joined: May 2006
- Online
There's probably a better coder term for it, but I think of it more that {} only supports static values. Ie, a number. If you're constructing a vector by calling functions, or calling the result of other point attributes or vectors, you need to use set().
An alternative way is to set the components individually, which can be easier to read in some circumstances.
v@myvector;
@myvector.x = rand(@ptnum);
@myvector.y = 2;
@P += @myvector;
An alternative way is to set the components individually, which can be easier to read in some circumstances.
v@myvector;
@myvector.x = rand(@ptnum);
@myvector.y = 2;
@P += @myvector;
-
- Quick Links