Grasshopper

algorithmic modeling for Rhino

Let's just say you're doing something dangerous and you would like to save a copy of the current definition, as it stands, to a temporary folder (C:\ghCrashPrevention\). 

There's a lot of magic in GH_IO.dll, but I really can't get my head around it. 

GrasshopperDocument.Write()? 

Any help would be appreciated.

Views: 767

Replies to This Discussion

Instances.DocumentEditor.ScriptAccess_SaveDocumentAs(Pach as String)

wonderful, thanks! works like a charm. A bit confusing usability wise, as then the definition thinks it's now saved in my temp location, and not in its original place, but alas. it works. 

and i'll have to rely a bit more on the autosave functionality. 

Got it working with your help. The magics are all in the bloody GH_Archive class.

With some further quick digging got this to work:

string ghSavePath = Path.Combine(FOLDERLOCATION, "ghdef.ghx"); 
GH_Archive myArchive = new GH_Archive();
myArchive.Path = ghSavePath;
myArchive.AppendObject(GrasshopperDocument, "Definition");
myArchive.WriteToFile(ghSavePath, true, false);

The above code will dump your gh definition in the location of your choice, slient and won't clash with where the def is currently saved. 

xxx

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service