Grasshopper

algorithmic modeling for Rhino

I have a question regarding strings and numbers... I'm reading in 2 lines of data from an Arduino board (these numbers are coming from an accelerometer...so that both numbers will change every time the Timer Component fires). This data is being printed in the out box of a VB.NET component... and in order for them to keep their formatting (meaning... each number will have their own index number in the Post-it Panel) the numbers are actually being read in as strings... If I change the print command in the VB.NET to something like: "Print(CInt(Val(StoredValue)))" then the strings are converted to doubles (so I can use them as numeric data in other components)... but it puts both numbers in one index item in the post it panel. So, instead of having two 3-digit number (each on their own line), I get one 6-digit number (in the example below, the post-it panel would just read 181130). In the image below, you can see it's reading both numbers in and keeping the formatting (each on their own index number)... I plan to just use a dispatch component to then split the list into two and isolate each number separately... but you can see the number parameter is red, because it thinks both numbers are strings. Is there any way to convert a string into a number?

Views: 5434

Replies to This Discussion

Actually, I think I may have just figured it out... I think all that I had to do was to pass the string into a "Generic Data" parameter... then feed that into the tokenizer functions and poof... magic... a converted string into 2 numbers (split by a comma)... I'll have to try it out when I get home tonight... but hopefully this theory works. Take a look at the screenshot below.

Starting to second guess my method... you don't need the Generic Data component... it's not really doing anything... I think the main thing I need to do is to make the data coming over the Serial Port come in on one line (so all the data is being printed in just one Serial.println command... I've been using several (Serial.println(byte(accx)DEC)) and another one for the comma and the accy... so, I'm getting a multiline data string... When I tried the definition above on a text string that allows multi-line data... It no longer worked... So, I think the obvious solution is just put all of the accx, "," , and the accy into one single Serial.println... then hopefully the code above should work... I'll test it out and report back. Hopefully a video coming soon.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service