I am trying to compile a test component importing PyDev code into the GHPython component. Is it possible at all? I wonder if somebody already tested it.
However, on the quest of trying it out myself, I discovered another problem. The PyDev workflow which has been working so far with Rhino 5 is not working in Rhino WIP. Did someone encounter the same problem?
For Rhino 05, I have recently configured PyDev following this:
In order to update the workflow to Rhino WIP, I used the new RhinoCommon.dll and RhinoCommon.xml files to make PyDev see Rhino. That seems to be working fine. However, on the RhinoPython side, I am not being able to make Rhino see PyDev. I have a — Runtime error (ImportException): No module named ‘my module name’ — returned. I did double check whether my Eclipse module was linked to the Rhino Python Options.
I think you mean ‘run Python code from an external editor (IDE)’, right?
There is also functionality regarding compilation, but I think that it not what you are looking for, I think.
The error _“No module named ‘<_somename>’.” means that <somename>.py is not to be found in any folder listed in the sys.path variable. You can add that folder dynamically to sys.path
import sys; if not mypath in sys.path: sys.path.append(mypath)
or go to EditPythonScript → Options → Module search paths (this is for Rhino for Windows only).
Nope, I would like to know whether it is possible to compile components even when importing parts or all the code from PyDev. That is the ultimate goal.
I promise I didn’t re-start Rhino and now the Python component runs without adding the path dynamically! Would love to know why Just as a matter of feedback, bellow is the difference of speed between adding the path dynamically (top) and having it loading normally from the RhinoPython editor:
With that sorted, we are back to the initial question:
How to compile the components utilising that workflow? When I try to compile that component here is the error I would appreciate some help with:
Sorry, we will have to see if this happens again (not finding paths in sys.path). It seems strange.
I am not sure why it would take 240ms to check if a string is in a list and to add it if not. It seems this might be doing something more. Have you tried re-computing the whole definition? If you haven’t restarted Rhino in 5 days, it might be a good time to try that anyways.
–
About compiling: your setup will not work automatically. It will work automatically only if you have all your code in the component. Also, reload() is definitely a no-go for compiling. To compile this, you will need to set-up a folder where you want everything to compile. Then, copy the “compilable code” from the folder. You will have to save that, too, in the compile folder. Follow the instructions that appear after copying the code to clipboard. I need to make a guide with an example, just not today I think.
Yes, when it started running without the dynamic call, I re-started Rhino straight away to check and both manners are working. I will run some tests and will report if any problems.
– (good idea!)
With regards to reload(). I didn’t know that it is a no-go for compilation, many thanks. Why? I was utilising reload() because if I don’t, the changes that I make to the code in PyDev just take effect if I reload Grasshopper itself.
With regards to the setup. I will follow the instructions, but still did not fully understand. Does that mean I will have to compile the code to this folder and import the directory in PyDev? Pardon, I am a bit confused. l will keep tuned for the guide.
Unfortunately I am still not set. I will keep trying but, as usual, would appreciate some help.
I forgot about PyDev for a second and I tried to compile the code bellow, just for testing if there was something wrong with the compilation process itself and here are the results:
I think you might be another victim of “extra installs of IronPython” . There seems to be a conflict between the version installed by Rhino and an independent install.
OK; this is better. Let me write a guide, test this in the last WIP (we have made some changes recently) and then I will get back on compiling, OK, Miriam?