Hello! I would like to get some Python now, I will be glad to any materials, if only they were not so huge and they could be understood
Hi,
if you are a real beginner to programming this is a great starting point. Once you know basic Python,
you could start using Python in Rhino. Just be aware that Python3.x and IronPython (Python 2.7) can differ in syntax.
Here is Rhino.python documentation that includes some fundamentals: http://developer.rhino3d.com/guides/rhinopython/
And the rhino.python 101 is a good primer also: http://developer.rhino3d.com/guides/rhinopython/primer-101/
And three is this series from Modelab on video: https://www.youtube.com/playlist?list=PLGV167zE8gnVhurBT46afZ1RlK9RzAsLx
Yes, great, there are a lot of good materials, but I would like a little practice. And I will be very happy if you give me some of your time and help me write one small script, my first script!
Hi,
Just make a beginning and ask about what issues you run into,
Post you code to be readable like so:
#This is code
print 'Hello World'
-Willem
@Willem, yes, thank you! But Iām just starting
The docs have a your first getting started guide. And each of the fundamentals has sample code. Here are samples : http://developer.rhino3d.com/samples/
Open editpythonscript command.
Well, it seems that I understand the basics, but I absolutely donāt understand how to approach the solution of the problem. I will be glad of any activity, as it will most likely be difficult and Iāll simply ābombā my questions! Now Iām just getting ready ā¦
The process of learning has to be to first just write out the sample code and play with it. There are many samples to play with there. Understand how to change the code and re-run the examples. After understanding some of the basic syntax only then can you determine your approach to solving a problem.
By the way, what is the problem you are trying to solve?
Sure! I think itās better to start with ā¦ Is it possible to somehow select a random object in an existing document?
Are you sure? If I would need to relearn programming from scratch, I would learn the language first. Sure tinkering around with scripts is a nice starting point and its a great way of keeping motivation. However from an educational standpoint its much easier and lasting if you understand the language, with all its flaws and advantages. Just as you said, the biggest question mark is how to become able to solve problems by yourself.
Therefore you need to know the tools. Just as you need to know the most important commands within Rhino to be able to model a shape.
On top of that, the skill of reading library documentation and error messages is very helpful. Debugging in general. The earlier you learn all this, the faster youāll progress.
Do you mean prompt the user to select any object. That would be a get object method: http://developer.rhino3d.com/guides/rhinopython/python-user-input/
Or do you mean truly random using a random function?
Thank you, but thatās not quite what I need. Yes, there are many useful functions, but Iām specifically interested in how I can select an object without using a mouse, without doing anything at all. It is possible by ID, but here it will still take a few clicks, since you need to get it first. Can I somehow randomly select objects and carry out operations on them?
Sure - collect all the selectable objectsā IDās with rs.NormalObjects(), then use one of Pythonās native random methods to randomly decimate the list into the number of objects you wantā¦ then do want you want with those.
Yes, thank you so much! I also thought about something like this and found
However, I donāt get this, I will be very glad if you explain some fragments

Are there lines that do make sense to you? and which fragments specifically do you not understand?
Yes, I think there is something to be learned. And I would like to know ā¦ Why are function calculations assigned to 2 variables? Why is the ārcā variable here?
rc, layername = Rhino.Input.RhinoGet.GetString(āName of layer to select objectsā, True, layername)
Some methods in RhinoCommon return both a success/failure boolean value, plus some sort of data value(s) - but the second maybe only if successful. So normally you first look at the value of rc
and if it is True
, then you can look at the second (or other) element(s) in the return list; if rc
is False
, it means the function failed and you do not need to look further.
There does appear to be some debate about what the name rc
actually stands for: