Jump to content

IF condition result makes no sense

Recommended Posts

Hello again!

I have a simple IF condition here that fetches an attribute value from a geometry & prints a result according to the comparison but for some reason it's not behaving as expected.

It's just 2 nodes & very simple yet as a non-programmer I'm scratching my head. If anyone can take a look & tell me what I did wrong I'd really appreciate it :D



Link to comment
Share on other sites

You're trying to fetch the X component of your point's P attribute, but you're just going about it the wrong way.

P is a vector, and you can't just fetch a piece of an attribute... you have to fetch the whole value. So instead of "int point_to_compare" you'd need to use "vector point_to_compare", and just fetch "P" instead of "P.x". (Incidentally, P.x would be a float, if you could fetch it that way.)

Once you have that vector, you can just compare "point_to_compare.x" against 0 and the rest of your code should work as expected.

  • Like 1
Link to comment
Share on other sites

I ran into another small problem :-|

It's with the "point" function this time. I want to specify a specific node to grab the attribute from, rather than input 0, 1 etc...

The help states that the geometry parameter can be a string... so I put a relative path but it's a no go.


Link to comment
Share on other sites

That did it lol. Not sure why I didn't have to use the "op:" in the For Each copy tutorial in the help...

Same "point" function, didn't need "op:"... strange. The exact line in the exercise was:

point("../foreach_begin1", 0, "divisions", 0)

I think because it's a "point" expression & not a "point" vex function... ahhh, contexts contexts... Thanks again toad!

Link to comment
Share on other sites

yep, you're right! the point expression syntax doesn't work the same way as VEX.

generally speaking, in VEX when you're trying to grab data from something that's not directly connected to your given node, you need the op: syntax to signify that you want to fetch the underlying data. for example, the point() function's help shows that the first parameter is <geometry>, not a string. the op: syntax signifies that you're trying to cook that operator and return the geometry data. similarly, you use op: syntax to fetch pixel data from COPs when you want to use a COP as a texture input rather than a file on disk.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...