algorithmic modeling for Rhino
Hi!
I need to fill in the multiple integer data set into the Integer Parameter in Rhino.
I've tried using standard
Call GH.AssignDataToParameter( "7c826015-a042-44d9-9ee6-98d6affb5119", strParse(1)),
which almost works...
I have 5 integer values in one string:
- When my input is the string "(25,0,0,0,175)" it is not assigned at all
- when my input is the string "25,0,0,0,175" it is assigned as 25000175 :)
- when my input is the string "25|0|0|0|175" it is assigned as 191 which is completely confusing :)
Can anyone point me into correct syntax of input string to be correctly parsed as a set of integers? I'm accessing Rhino+GH from external app so I can format the input in any appropriate way, yet I cannot directly modify the GH script that uses these Integer Parameters as a way to handle input.
Regards,
Boris
Tags:
The string (25,0,0,0,175) does not evaluate to an integer (it doesn't evaluate to anything, it's not a valid expression).
The string 25,0,0,0,175 works even though it too, is not a valid expression, but the commas in this case are interpreted as group separators (as in 1,573.99) and are thus ignored.
As for the mysterious one, 25 written in binary is 00011001 and 175 written in binary is 10101111. The vertical bar symbol is the C-language OR operator, which results in a 1 if any of the inputs is 1. Thus:
00011001 OR 10101111 = 10111111
which equals 191.
To make it work you should call AssignDataToParameter not with a single string, but with an array of 5 items.
Dim array()
ReDim array(4)
array(0) = 25
array(1) = 0
array(2) = 0
array(3) = 0
array(4) = 175
Call GH.AssignDataToParameter(id, array)
Call GH.RunSolver(False)
My RhinoScript at the moment doesn't work for some reason, so I couldn't test this.
--
David Rutten
david@mcneel.com
Thanks David!
I knew it was something stupid, I'm just too tired today to think...
It works after changing the script to:
Dim arrResult
arrResult = Split(strParse(1), ",")
Call GH.AssignDataToParameter( "a6097460-0d1d-4c39-bc6a-b19b1099f900", arrResult)
Cheers,
Boris Zapotocky
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by