alr77 Posted April 24, 2021 Share Posted April 24, 2021 (edited) Dear all, Good Evening, So, i was digging into the VEX functions "string" section. And i didn't found any clue to chop a string into an array. string myString = "1234Abc"; The goal will be to get this below : string arrayFromString[] = {"1","2","3","4","A","b","c"}; As well in python it is "native" : myString = "1234Abc" myString[0] would be "1" etc etc.... But to use it in a wrangle i need VEX ....If anybody has a clue . It will be 100% Welcome, as it could be a very simple way to chop and bytecrush long floating numbers. Might it be a NOOB question and i apologize already for that. Thank you a lot, And all the best to everybody with Houdini !!! alr + + + Edited April 24, 2021 by alr77 Quote Link to comment Share on other sites More sharing options...
alr77 Posted April 24, 2021 Author Share Posted April 24, 2021 Ouupsss.... Thousand apologies...... I tried : string myString = "myString"; printf("%s",myString[0]); and it worked..... it printed "m". so if anybody as me primarily thought a built-in method was required to do this. it is not the case. It is native as in Python. Good evening, and sorry ! Houdini it is so great. alr + + + Quote Link to comment Share on other sites More sharing options...
alr77 Posted April 25, 2021 Author Share Posted April 25, 2021 (edited) So...sorry for the "OUPS post just before". If some are curious about the result of "my crushing decimals string approach". Please find the VEX below : Plug any geo, create the slider decimalsTrim and test. float floatCrushing(float myFloat; int decimal) { //VAR INIT: float crushedFloatValue = -9999; string crushedStringValue = ""; //CRUSHING : string stringizeMyFloat = sprintf("%s",myFloat); int match_science_notation = match("*e-*", stringizeMyFloat); if(!match_science_notation) { //CRUSH THE STRING VALUE : int byteSize = strlen(stringizeMyFloat); for(int byte=0; byte < byteSize; byte++) { crushedStringValue += stringizeMyFloat[byte]; if(stringizeMyFloat[byte] == ".") byteSize = byte + 1 + decimal; } crushedFloatValue = atof(crushedStringValue); } else { //KEEP CURRENT VALUE : crushedFloatValue = atof(stringizeMyFloat); } return crushedFloatValue; } //TEST ON point "P" : vector anyVector = {0,0,0}; for(int chan = 0; chan < 3; ++chan) anyVector[chan] = floatCrushing(@P[chan], chi("decimalsTrim")); @P = anyVector; The goal was to start from High definied geo to harsh geo in a "minecraft" way or 80's CGI. Here normal Geo Here one decimal Geo. As well add a fuse at the end. Change the code to make it works on single float or else, you can also "crush" any Cd vector or noise or else. And sorry for my "OUPS question ^^". If you find any use for you, it is cool. (on my side i needed it hehe^^). Good evening, Thank you, bests, alr + + + Edited April 25, 2021 by alr77 1 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.