Hi Folks,
tl;dr:
I’m trying to make a script taking a list of rhino/grasshopper file pairs that will:
- open the rhino file
- open the grasshopper file (bake=True with bakename)
- let the grasshopper file attach any number of worksession 3dm files
- close the grasshopper file
- save the rhino file with the new baked geometry (elefront replaces the old geometry with the same bakename
- close rhino
repeat for the whole list
This process works fine without the step 3 (the worksession part), but it’s of little use to me as such.
How can i get around this? Is anyone else automating worksessions?
Basic problem:
This is a small example consisting of two .3dm and two .gh files
1-points.gh (14.8 KB)
2-lines.gh (18.5 KB)
A-points.3dm (142.4 KB)
automationTest.py (1.5 KB)
B-lines.3dm (32.0 KB)
LONG STORY
I have been using elefront for some time now and it has enable a very powerful workflow for Architecture and Engineering projects. Generally it means large detailed projects can be broken down into a network of small manageable pieces.
Practically it means several people can work on different parts of the project simultaneously at the same time. Critically rhino files are connected via worksessions.
On the current project we are designing the structure for two similar free-form building fcades. Each building consists of 10+ rhino files and almost 50 (shared) grasshopper files.
Having the project broken up into these manageable steps means that each time critical input value or piece of geometry changes, we can run all downstream processes, checking each step on the way.
Since change frequency is pretty low, the manual process of opening each rhino file and running the appropriate grasshopper definitions is ok.
It occurred to me that it should be straightforward to stitch this process together and automate the entire update process using an external script (python or c# preferably). I’d especially see the value in using something like this on projects with higher frequency changes.
I made a small python library which does this, essentially by opening a specific rhino file and a specific grasshopper file using command line args like this: C:\Program Files\Rhino 6\System\Rhino.exe /nosplash /runscript="-grasshopper solver enable load document open {GH_FILEPATH} _enter -save _enter -exit" {RHINO_FILEPATH}
I have attached a bare bones example of this script above. filepaths may need changing
The problem is that most of our definitions contain a python node which attaches a list of specific rhino files to the worksession. Since worksessions have very limited sdk support
this means that we are forced to use rs.Command
#P is a list of filepaths to attach to worksession for p in P: #command must be surrounded with '' so that file path can e surrounded with "" #this ensures that paths with spaces still work rs.Command('-Worksession Attach "{}" _Enter'.format(p))
Unfortunately this means that any part of the initial command line argument after the worksession command will not run!
I started to explore using COM and the RhinoScript object to launch rhino instead, but this seems to suffer from the same problem. Here is the console app code Program.cs (3.9 KB)
@Rickson I understand you use this kind of AEC elefront workflow too. Any tips?
@dale i think this is essentially a request to get more SDK support in RhinoCommon eg: Rhino.RhinoDoc.Worksession.Attach()
Rhino.RhinoDoc.Worksession.Detach()
Rhino.RhinoDoc.Worksession.Current()
Rhino.RhinoDoc.Worksession.Refresh()
Rhino.RhinoDoc.Worksession.Open()
Rhino.RhinoDoc.Worksession.Save()
Rhino.RhinoDoc.Worksession.SaveAs()
further to https://mcneel.myjetbrains.com/youtrack/issue/RH-49088
Looking forward to hearing from all you friendly creatures