Grasshopper

algorithmic modeling for Rhino

Hello,

 

I have been searching through the forum for a bit looking for a bit of VB script that will give me current timedate that I will be able to add to string. I haven't been able to find anything, and I've had an attempt at a VB script but I really don't know what I'm doing.

 

What i'm doing is building comma separated strings in lists and then exporting to excel. I would like for there to be a current date (can be fairly rough) in the string that I export.

 

I was trying to get =NOW() to work in excel, but i need it to be unchanging, and from the date I pull the data from grasshopper. 

 

Does anyone have any ideas. I have an image of what I would like it to do (theoretically).

Views: 7234

Attachments:

Replies to This Discussion

Hi Will,

 

I use:

 

private void RunScript(object x, object y, ref object time, ref object hours, ref object minutes, ref object seconds)
  {
    time = System.DateTime.Now.Date;

    hours = System.DateTime.Now.Hour;
    minutes = System.DateTime.Now.Minute;
    secnods = System.DateTime.Now.Second;

  }

 

Hope it´s useful.

Cheers!

here i made couple of components including these ones

http://www.grasshopper3d.com/group/localcodecomponents/forum/topics...

Not really what you were looking for I suppose.

 

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

 

Attachments:

Oh my gosh... that's perfect David. I guess I just needed clarification on how to use the time parameter. When I read the remarks under "help", i didn't read it clearly, and thought the parameter didn't have any current functionality.

 

What else can you plug in besides today, yesterday, tomorrow and now. Can you modify the format of the output?

It also accepts "Lunch", "Next Week" and "Last Week" as string constants, but they're not really meant as serious conversions.

 

I originally added the DateTime parameter because I thought I'd end up writing a solar-angle component, but I've never gotten around to that.

 

Dates are stored as 64-bit integers. Basically they count Ticks (1 tick = 100 nanoseconds, or 1 second = 10 million ticks) since midnight, January 1st, 1 AD. Formatting comes into play only when the time is represented as a String.

 

A wide variety of formatting flags is possible Dates, unfortunately the Grasshopper Expression language doesn't support the DateTime type, so it gets converted to Strings automatically. This makes formatting dates and times impossible. I'll probably get around to adding the type at some point, or maybe I'll make a dedicated DateTime formatter component (less work, but also less flexible).

 

I also do my best to interpret any string that might represent a date or a time:

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi David, I have a table of formatted time date strings that the Time parameter can read and format, but i would like to then take these dates and make date ranges/ domains and apply Boolean commands. Is this at all possible with the time string or do I need to convert these dates back into Integers?

If not, Is it possible to easily do the reverse of this time date conversion to generate the integer value from a list of dates/times?

Note that a DateTime object stores ticks as Int64 (64-bit integers). The Grasshopper integer type is only 32-bit. This means you cannot convert a Datetime tick count to a Grasshopper integer and back as Grasshopper integers simply cannot handle the magnitude of the numbers involved. 32-bit integers can only count up to 2,147,483,647 whereas 64-bit integers can count up to 9,223,372,036,854,775,807

 

There is also no data format in Grasshopper for representing time-spans or durations. It's probably not too difficult to write some VB.NET script components that do what you need, but you'll need to tell me exactly what types of data you have and what data you're looking for.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks for the explanation David.  That makes perfect sense.   As you allude to in the second part of your post above, I'm currently working towards setting up a system to convert the datetime string to a rationalized integer format for use in the grasshopper definition .  I don't want to convert the information permanently, but have been looking for an elegant method for converting the datetime string as needed so that it can interface within a grasshopper definition.

What I am trying to do is create a process for working with the timestamp included alongside sensor data I pull from Cosm.  The data feed is formatted like this; <current_value at="2012-07-25T05:24:44.601988Z">77.68</current_value> and the Time paramater seems to easily understand the datetime string to read  2012-07-25T05:24:44.601988  as  Wednesday, 25 July 2012 (05:24:44)  so I plan on keeping the string as is when stored in a local mySQL database I have setup, but want to make sure I am not setting myself up for major headaches down the road.

I asked about converting the date time string to an integer to allow me to find time spans and generate a series of time stamps in an efficient way for creating a batch/ iterative process for requesting additional sets of data based on a query comparison of what gaps are left to fill in along a timeline of data points.  

At the moment, I think a conversion to an integer is my best bet. (ref; Excel Date Time Code  Id love to be able to feed in a date into a math component, add 08:00:00 and for it to result with a time 8 hours later than the first.  I also have a string manipulation method working also, but have yet to really test it beyond what I have shown in the screenshot below.  

I currently have these batches stream from Cosm.com into Grasshopper via a xml parser component (either the one found in Andy Payne's Firefly set, or the one included in gHowl.) From there I sort/ extract the data points and their respective time stamps and feed these data points into a mySQL database I've setup with Nathan Miller's Slingshot components.  With the points in a local SQL database, I can then begin to integrate the use of database queries into definitions and retrieve data points based on sensor value Booleans rather than being restricted to time spans, (which is the only way to request historical data from Cosm's site)

I've been debating on if I should convert all the time information to an integer before writing it to the SQL database so GH can work with the data, or if I should keep the time code as a string and create a couple of conversation component clusters to translate the information each time it needs to be processed or manipulated in GH.  I'd prefer to keep things in the date time string because the database can handle it without a problem, GH sort of handles it in one translation direction and allows me to avoid conversion that Id have to explain to others if they were to access the database in their own grasshopper definition or from another application.

I think the best solution is to use strings to represent time intervals. It's lossless and as long as you know what you're doing you won't run into casting bugs. I attached a file with a bunch of VB component that perform several typical operations on times and timespans, hopefully it will get you started (and hopefully you can open the file as it was saved with 0.9.0002).

It's midnight here and I won't be in the office tomorrow, so I'm afraid I won't be able to respond to any further questions until

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

Your incredible David.  The components opened flawlessly and are exactly the tools I had been looking to solve.  Thank you for the help today and all of the timetool components.

Any news on when 0.9.0002 might drop?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service