algorithmic modeling for Rhino
Hi all!
I was wondering whether there is a way to call a python script, which imports rhinoscriptsyntax, from OUTSIDE Rhinoceros. I know that Rhinoceros includes a Python interpreter but, as Steve Baer told here, "Rhino doesn't ship with a console program that would let you run python scripts from the command line".
I have installed IronPython in my PC and I have tried to "move" rhinoscriptsyntax.py to the ironPython module folder but, unfortunately, I could not find such rhinoscriptsyntax.py in the Rhinoceros installation.
Finally I have installed Grasshopper and ghpython hoping that I could use it from the MS-DOS window, but I do not know how to do it.
The reason to execute a python script from MS-DOS is that my program have to call Rhinoceros inside a loop to generate geometry at the beginning of each iteration. The only way I know to do that is to write:
Rhino /nosplash /runscript="!_-RunPythonScript "file.py""
where file.py changes in every iteration. But the latter command will open Rhinoceros in each iteration, making my program very slow.
Thanks in advance,
Fran Pena
Tags:
Hi Fran,
From what you have said, it is difficult to see a solution for you. It sounds like you are doing something in a way that is much more difficult than it needs to be. If you'd like help, you should describe the task you are trying to accomplish. People may have suggestions for how to make the task much easier, and even to avoid using IronPython outside of Rhino. What are you doing in "file.py" that requires you to run it from the command line? Why are you running a script that changes another script?
Two possible things to look at which may help:
Hi Benjamin,
Thanks you for your kind advise. Here is the problem: I have to deal with an optimization problem; basically, I have to run an iterative process where, in each iteration, I have to create
My first guess was to create a python script containing the iterative process and call it from MS-DOS; your idea of running the whole program inside Rhino can work, but only if Salome + CA does not have a requirement similar to Rhino (I still have to investigate that point). Maybe, a python script in Salome can be called from outside Salome, in a similar way Rhino is called with the command:
Rhino /nosplash /runscript="!_-RunPythonScript "file.py""
But these could imply that a graphical window is opened in each iteration and, since the whole process can involve several hundred iterations, the time to open and close a graphical window in each iteration is not negligible.
Of course, the possibility to access to the rhinoscriptsyntax module is still the best solution for me since:
Thank you in advance for any suggestion you have.
Sincerely,
Fran Pena
Here's what I would try, in your situation:
I would also see if Salome + CA can be run on command line (it appears likely). If so, I would create one script in Rhino that runs the whole thing, and calls external python scripts to run analysis in Salome + CA. I would still store geometry using cPickle.
I'm not sure if either of these will work, but that's how I would approach it. I hope this helps.
-Ben
Hi Benjamin,
your approach seems promising. Let me try and I'll tell you about.
Sincerely,
Fran Pena
Did the proposed approach work for you?▼ Reply
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by