Grasshopper

algorithmic modeling for Rhino

Hi guys,

I'm trying to create an excel file, but I'd like to have a proper output name, using date and hour in the name (GH definition_YYYY-MM-DD_HH-MM.xls).

One question is how to ask to GH to generate an excel file establishing the name of the file directly form GH.

The second issue is that I put both "Deconstruct Date" and "clock". The first one never updates itself and the second one updates itself only if I double click on the component.

Could you please help me?

Thanks a lot

Views: 385

Replies to This Discussion

You could use a snippet something along the lines of this in a C# block to get what you want. It gets the current filename and the current date.

    string filename = "undefined";
    if (GrasshopperDocument.FilePath != null)
    {
      filename = Path.GetFileName(GrasshopperDocument.FilePath).Replace(".gh", "");
    }
    DateTime Now = DateTime.Now;
    A = String.Format("{0}_{1:0000}-{2:00}-{3:00}_{4:00}-{5:00}.xls",
      filename,
      Now.Year,
      Now.Month,
      Now.Day,
      Now.Hour,
      Now.Minute);

Thank you! it's working well.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service