this is the link to the recource I have been following along with.
currently going through the document, and dipping my toes further into the python in Rhino world.
however Idk if this because the document is outdated maybe, but I am running into many many errors as I try to implement the scripts in the document. for example the starting import statements don’t seem to apply in the rhino script editor but in the GH editor they do, “rs.” has to be replaced by “rhino.” and even then execution seems rare, some methods simply don’t seem to operate properly at all eg rs.getobject.
many of the scripts which require no additional global definitions are not running, for example the clock script in the document around page 27 does not execute. I have copied scripts straight into the rhino and GH compilor as is to find out they are not functional, and no amount of tweeking gets the scripts to execute.
any help in regards to the nature of this recouce would be appreciated and maybe some other sources with a more practical and updated approach to teaching scripting in rhino. my knowledge of syntax and correnctness of code is also still under developed and perhaps this is the reason for my frustrations, however the issues I am running into seem to be unrelated to that facet.
Thank you for any help
AFAIK, the Rhino Python primer covers running Python scripts directly in Rhino, not in GH. The two are not interchangeable, scripts written for Rhino outside of GH cannot simply be pasted into a GH Python module and expected to work. For example
rs.GetObject()
is designed to allow the user to pause the script and select objects on-screen, and returns their GUID’s. Existing objects in the Rhino document are referenced in GH via Parameters or Model components and do not need this. It is of course possible to adapt scripts designed to run outside of GH to be able to run inside a GH Python component, but that adaptation requires a fair amount of knowledge about how both systems work.
Also, it is possible that the examples in the primer are using methods that have changed or are deprecated. It was written for IronPython2, whereas, depending on how you have things set up, in V8 you could be trying to run your scripts in Python 3.
If you have specific examples of something that is failing, please post the code here and someone will look.
Thank you for your answer, I am working in V8 so it would be Iron python 3, I tried running scripts in both the rhino and the GH, I would get no results back from both on some scripts so it led to me writing this post, I have however run some scripts from the PDF and it managed in produced baked and finished geometry out of the python GH compilor. would this have to do with the type of method being called out and weather it can run outside or without the rhino UI.
again thank you for your reply and if you have any recources that would make my life easier when it comes to learning I would very grateful.