Trancor Posted July 21, 2015 Share Posted July 21, 2015 (edited) Hey guys, I searched around for this and can't seem to find a solution, maybe you guys know.To simplify what I'm doing (its quite more complicated than this, but, ya know), lets just say I have this set up-string A = "91+";string B = @ptnum;string C = A+B;C == "91+1", "91+2", "91+3" . . .Is there an eval I can do in VEX to get a result like this per point?9192939495I've tried doing things like -float( C ) == errors outoratof( C ) == "91" But it doesn't seem to work for me.Is there any sort of - eval( C )Or another way to evaluate the string variables as an expression/math?I'm considering just adding new parameters to evalutate the math through python and to read the parameters into the vex, but is there an easier way to do this? Edited July 22, 2015 by Trancor Quote Link to comment Share on other sites More sharing options...
3iart Posted July 21, 2015 Share Posted July 21, 2015 (edited) I'm completely guessing, but could this work string A = "91"; string B = @ptnum; string C = ftoa(atof(A)+atof(; having the operator "+" in the string is a bit of a problem I think. Edited July 21, 2015 by 3iart Quote Link to comment Share on other sites More sharing options...
pezetko Posted July 21, 2015 Share Posted July 21, 2015 // preview of attributes string A = "90"; string B = sprintf("%d",i@ptnum); // atof() converts string to float, sprintf print sum of i@ptnum and A to string @C s@C = sprintf("%d",i@ptnum+atof(A)); Cheers, Petr Quote Link to comment Share on other sites More sharing options...
Trancor Posted July 22, 2015 Author Share Posted July 22, 2015 (edited) Hey guys, thanks for the replies.The problem is, I can't remove the +Its goin to be "90+" or "sin($F)+" or some variant with the operators built into the string being passed.Thats why I was hoping for an eval command to process the string like a math problem.eval("91+5*"+@ptnum); Type of thing.atof( ) only grabs the first number in the string it finds, as it appears. Edited July 22, 2015 by Trancor Quote Link to comment Share on other sites More sharing options...
fathom Posted July 22, 2015 Share Posted July 22, 2015 how is the string being generated? Quote Link to comment Share on other sites More sharing options...
Trancor Posted July 22, 2015 Author Share Posted July 22, 2015 (edited) User input basically.It'll find a string like "40*5+@ptnum" and I'm just looking to get the value of that math in VEX.To mimic eval( ) from any number of other scripting and programming langues. Edited July 22, 2015 by Trancor Quote Link to comment Share on other sites More sharing options...
fathom Posted July 23, 2015 Share Posted July 23, 2015 can you use snippets? check out some of the pop nodes like wind. they have user entered vex code as part of their functionality. Quote Link to comment Share on other sites More sharing options...
Trancor Posted July 23, 2015 Author Share Posted July 23, 2015 Not in this case, I sort of gave up and just added a VEXpression parameter, I guess similar to snippets, but to set point attributes for the code I'm writing to read from.Annoying, but works. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 23, 2015 Share Posted July 23, 2015 You would need to write a parser to make it work with a string input. Probably have to use the HDK to extend VEX for something like that. Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted July 23, 2015 Share Posted July 23, 2015 (edited) Maybe this is your answer: 1. http://www.sidefx.com/docs/houdini14.0/hom/pythonsop 2. http://www.sidefx.com/docs/houdini14.0/hom/hou/runVex 3. http://stackoverflow.com/questions/9383740/what-does-pythons-eval-do ? Edited July 23, 2015 by fântastîque Mântragorîè Quote Link to comment Share on other sites More sharing options...
anim Posted July 24, 2015 Share Posted July 24, 2015 you can as well insert content of user input parameter into your vex code some vex code `chs("../userinputparm")` more vex code; it will get expanded before compilation, then it will evaluate as a vex code it won't work however for animated parms as it get's expanded only on the first frame Quote Link to comment Share on other sites More sharing options...
Trancor Posted July 24, 2015 Author Share Posted July 24, 2015 (edited) Thanks everyone.Captain, I think that might be the solution here. Not a fan though, hahah.Since its all VEX, parsing out the string in python and applying any particle numbers seems futile to me. I got around it with just opening up a VEXpression input on my otl, changes workflow a little, but at least it works. I just figured, every languages I've ever used had an eval command, was sort of hoping VEX had Edited July 24, 2015 by Trancor Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.