Grasshopper

algorithmic modeling for Rhino

I received a random question in my email about how to programmatically launch a file dialogue to save a Grasshopper file.

Using a C# component you could drive this with a Boolean Toggle like so:

GH_DocumentIO docIO = new GH_DocumentIO(GrasshopperDocument);
if (save) docIO.Save();

If you want the document to automatically detect whether or not it's been saved and, if it hasn't, immediately launch the file save dialogue, do this:

GH_DocumentIO docIO = new GH_DocumentIO(GrasshopperDocument);
if (GrasshopperDocument.FilePath == null) docIO.Save();

Note that the GrasshopperDocument object exists as a Member in the C# component, otherwise you'd have to call it like this:

GH_Document doc = Grasshopper.Instances.ActiveCanvas.Document

Views: 967

Replies to This Discussion

SO SWEET thnx

Thank you! Please tell me how to set the file name when saving?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2022   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service