Jump to content

probably an easy syntax question


etudenc

Recommended Posts

Would someone be kind enough to tell me why the top expression works but the bottom one doesn't? Am I supposed to format a user-defined variable differently inside a function?

# working

{

return vector("[1, 2, 3]")[0] ;

}

#not working :(

{

float dirX = 1 ;

float dirY = 2 ;

float dirZ = 3 ;

return vector("[dirX, dirY, dirZ]")[0] ;

}

I've tried all kinds of variations such as:

return vector([dirX dirY dirZ]) ; (no commas)

return vector(["dirX", "dirY", "dirZ"]) ; (added quotes around each variable)

return vector([("dirX"), ("dirY"), ("dirZ")]) ; (quotes and parentheses)

return vector("[(dirX), (dirY), (dirZ)]")) ;

return vector("[(dirX) (dirY) (dirZ)]")) ; (no commas)

return vector("[(dirX)], [(dirY)], [(dirZ)]") ;

return vector("[dirX], [dirY], [dirZ]") ;

but no go.

Thanks for any pointers!

Edited by etudenc
Link to comment
Share on other sites

I'm no vex expert, but have you tried this?

return vector([dirX, dirY, dirZ])[0];

Cheers

Thanks rafaelfs, unfortunately I have but no luck. I'll edit my post to include the variations I've tried. Maybe in the process I'll land on the right one!

Link to comment
Share on other sites

this looks like Hscript

try this

{

float dirX = 1 ;

float dirY = 2 ;

float dirZ = 3 ;

return vector( "[" + dirX + "," + dirY + "," + dirZ + "]" )[0] ;

}

EDIT: but as rafael said, tell us what you are trying to do, you may get answer to your actual problem instead of jus little fix of your approach which may not be the most efficient

Edited by anim
Link to comment
Share on other sites

this looks like Hscript

try this

{

float dirX = 1 ;

float dirY = 2 ;

float dirZ = 3 ;

return vector( "[" + dirX + "," + dirY + "," + dirZ + "]" )[0] ;

}

EDIT: but as rafael said, tell us what you are trying to do, you may get answer to your actual problem instead of jus little fix of your approach which may not be the most efficient

Thank you, that worked! I was a long way from the answer!

I don't know if this is the most efficient way of doing things but for my current project I decided to create a control node (a NULL) so that I can add and centralize some parameters. Using some expressions in each parameter, I'm able to

- specify two points on whatever geo is plugged in to a transform SOP

- get their respective positions

- find the direction (a vector)

I want to normalize the direction but I got stuck trying to figure out how to normalize a value coming from a parameter so this is my roundabout way of making it happen. I tried passing the direction vector to a point attribute but the normalize node in the VOP SOP isn't giving me predictable results, so writing an expression seems like the next thing to try.

Thanks again!

Link to comment
Share on other sites

Thank you, that worked! I was a long way from the answer!

I don't know if this is the most efficient way of doing things but for my current project I decided to create a control node (a NULL) so that I can add and centralize some parameters. Using some expressions in each parameter, I'm able to

- specify two points on whatever geo is plugged in to a transform SOP

- get their respective positions

- find the direction (a vector)

I want to normalize the direction but I got stuck trying to figure out how to normalize a value coming from a parameter so this is my roundabout way of making it happen. I tried passing the direction vector to a point attribute but the normalize node in the VOP SOP isn't giving me predictable results, so writing an expression seems like the next thing to try.

Thanks again!

Let me see if I understand: having point A and point B, you want to be able to plug a transform SOP to point A so that it automatically moves to point B? Or do you just want to find the vector that would do such operation?

Both cases are relatively ease to figure out with either a VOP SOP or a point SOP and some expressions...

Cheers

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.

Guest
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...