Grasshopper

algorithmic modeling for Rhino

Save Grasshopper/Rhinofile from inside the ghPython component

Hey everyone,

i hope this is a simple question. I would like to save the active grasshopper and rhinofile from inside the python component. But i was not able to find a working solution in the Grasshopper SDK or Google ...

Thank you all for Help :)

Tobi

Views: 549

Replies to This Discussion

Hi Tobias

here is how to do it:

import Grasshopper as gh
import os

if active:
canvas_doc = ghenv.Component.OnPingDocument()
old_path = canvas_doc.FilePath
canvas_doc.FilePath = os.path.expandvars("%userprofile%\desktop\save_me.gh")
try:
if canvas_doc:
gh.Kernel.GH_DocumentIO(canvas_doc).Save()
finally:
canvas_doc.FilePath = old_path


import Rhino

if active:
options = Rhino.FileIO.FileWriteOptions()
options.SuppressDialogBoxes = True
Rhino.RhinoDoc.ActiveDoc.WriteFile(
os.path.expandvars("%userprofile%\desktop\save_me.3dm"), options)

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Attachments:

Thank you a lot :)

It worked perfectly fine ! 

I am really happy about this fast and helpful answer.

Have a nice evening

Tobias

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service