# Python right now

**URL:** <https://discourse.mcneel.com/t/python-right-now/105356>\
**Category:** Scripting\
**Created:** [July 8, 2020, 8:26am UTC](https://discourse.mcneel.com/t/python-right-now/105356 "2020-07-08T08:26:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Modeler3D](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/modeler3d/32/486828_2.png) [@Modeler3D](https://discourse.mcneel.com/u/Modeler3D)\
**Post date:** [July 8, 2020, 8:26am UTC](https://discourse.mcneel.com/t/python-right-now/105356/1 "2020-07-08T08:26:14Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gijs/32/769882_2.png) [@Gijs](https://discourse.mcneel.com/u/Gijs)\
**Post date:** [July 8, 2020, 8:39am UTC](https://discourse.mcneel.com/t/python-right-now/105356/2 "2020-07-08T08:39:14Z")

</div>

[![](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/4/c/4ce6c9f2f88ff23e8a9fe6d214c82d3bee08dd52.jpeg "The first 20 hours -- how to learn anything | Josh Kaufman | TEDxCSU") ](https://www.youtube.com/watch?v=5MgBikgcWnY)

---

<div class="post-metadata">

**Author:** ![TomTom](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/tomtom/32/651939_2.png) [@TomTom](https://discourse.mcneel.com/u/TomTom)\
**Post date:** [July 8, 2020, 8:39am UTC](https://discourse.mcneel.com/t/python-right-now/105356/3 "2020-07-08T08:39:14Z")

</div>

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.

[![](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/a/b/6/ab6b2c9549483b37e668cb9d3a19dac7fa11213f.jpeg "Python for Everybody - Full University Python Course") ](https://www.youtube.com/watch?v=8DvywoWv6fI)

---

<div class="post-metadata">

**Author:** ![scottd](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/scottd/32/494002_2.png) [@scottd](https://discourse.mcneel.com/u/scottd)\
**Post date:** [July 8, 2020, 8:45am UTC](https://discourse.mcneel.com/t/python-right-now/105356/4 "2020-07-08T08:45:07Z")

</div>

Here is Rhino.python documentation that includes some fundamentals: [http://developer.rhino3d.com/guides/rhinopython/](http://developer.rhino3d.com/guides/rhinopython/)

And the rhino.python 101 is a good primer also: [http://developer.rhino3d.com/guides/rhinopython/primer-101/](http://developer.rhino3d.com/guides/rhinopython/primer-101/)

And three is this series from Modelab on video: [https://www.youtube.com/playlist?list=PLGV167zE8gnVhurBT46afZ1RlK9RzAsLx](https://www.youtube.com/playlist?list=PLGV167zE8gnVhurBT46afZ1RlK9RzAsLx)

---

<div class="post-metadata">

**Author:** ![Modeler3D](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/modeler3d/32/486828_2.png) [@Modeler3D](https://discourse.mcneel.com/u/Modeler3D)\
**Post date:** [July 8, 2020, 9:30am UTC](https://discourse.mcneel.com/t/python-right-now/105356/5 "2020-07-08T09:30:11Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [July 8, 2020, 10:00am UTC](https://discourse.mcneel.com/t/python-right-now/105356/6 "2020-07-08T10:00:37Z")

</div>

Hi,  
Just make a beginning and ask about what issues you run into,  
Post you code to be readable like so:

```auto
#This is code 
print 'Hello World'

```

-Willem

![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/a/4/a46cd89d2167f80275359bb4f8a99286a2454c9f.png)

---

<div class="post-metadata">

**Author:** ![Modeler3D](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/modeler3d/32/486828_2.png) [@Modeler3D](https://discourse.mcneel.com/u/Modeler3D)\
**Post date:** [July 8, 2020, 1:44pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/7 "2020-07-08T13:44:00Z")

</div>

@Willem, yes, thank you! But I’m just starting 🙂

---

<div class="post-metadata">

**Author:** ![scottd](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/scottd/32/494002_2.png) [@scottd](https://discourse.mcneel.com/u/scottd)\
**Post date:** [July 8, 2020, 1:48pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/8 "2020-07-08T13:48:19Z")

</div>

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/](http://developer.rhino3d.com/samples/)

---

<div class="post-metadata">

**Author:** ![scottd](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/scottd/32/494002_2.png) [@scottd](https://discourse.mcneel.com/u/scottd)\
**Post date:** [July 8, 2020, 1:48pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/9 "2020-07-08T13:48:55Z")

</div>

Open editpythonscript command.

---

<div class="post-metadata">

**Author:** ![Modeler3D](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/modeler3d/32/486828_2.png) [@Modeler3D](https://discourse.mcneel.com/u/Modeler3D)\
**Post date:** [July 8, 2020, 2:44pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/10 "2020-07-08T14:44:05Z")

</div>

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 …

---

<div class="post-metadata">

**Author:** ![scottd](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/scottd/32/494002_2.png) [@scottd](https://discourse.mcneel.com/u/scottd)\
**Post date:** [July 8, 2020, 3:02pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/11 "2020-07-08T15:02:59Z")

</div>

> [@Modeler3D](#):
>
> but I absolutely don’t understand how to approach the solution of the problem

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?

---

<div class="post-metadata">

**Author:** ![Modeler3D](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/modeler3d/32/486828_2.png) [@Modeler3D](https://discourse.mcneel.com/u/Modeler3D)\
**Post date:** [July 8, 2020, 4:00pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/12 "2020-07-08T16:00:13Z")

</div>

Sure! I think it’s better to start with … Is it possible to somehow select a random object in an existing document?

---

<div class="post-metadata">

**Author:** ![TomTom](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/tomtom/32/651939_2.png) [@TomTom](https://discourse.mcneel.com/u/TomTom)\
**Post date:** [July 8, 2020, 4:40pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/13 "2020-07-08T16:40:16Z")

</div>

> [@Modeler3D](#):
>
> I understand the basics,

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.

---

<div class="post-metadata">

**Author:** ![scottd](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/scottd/32/494002_2.png) [@scottd](https://discourse.mcneel.com/u/scottd)\
**Post date:** [July 9, 2020, 1:08am UTC](https://discourse.mcneel.com/t/python-right-now/105356/14 "2020-07-09T01:08:14Z")

</div>

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/](http://developer.rhino3d.com/guides/rhinopython/python-user-input/)

Or do you mean truly random using a random function?

---

<div class="post-metadata">

**Author:** ![Modeler3D](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/modeler3d/32/486828_2.png) [@Modeler3D](https://discourse.mcneel.com/u/Modeler3D)\
**Post date:** [July 9, 2020, 2:45pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/15 "2020-07-09T14:45:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [July 9, 2020, 3:10pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/16 "2020-07-09T15:10:41Z")

</div>

> [@Modeler3D](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Modeler3D](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/modeler3d/32/486828_2.png) [@Modeler3D](https://discourse.mcneel.com/u/Modeler3D)\
**Post date:** [July 9, 2020, 3:39pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/17 "2020-07-09T15:39:27Z")

</div>

Yes, thank you so much! I also thought about something like this and found

> **[Select Objects on Layer](https://developer.rhino3d.com/samples/rhinocommon/select-objects-on-layer/)**
>
> Demonstrates how to select all the objects on a user-specified layer.

  
However, I don’t get this, I will be very glad if you explain some fragments 🙂 Good?

---

<div class="post-metadata">

**Author:** ![scottd](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/scottd/32/494002_2.png) [@scottd](https://discourse.mcneel.com/u/scottd)\
**Post date:** [July 9, 2020, 3:44pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/18 "2020-07-09T15:44:16Z")

</div>

Are there lines that do make sense to you? and which fragments specifically do you not understand?

---

<div class="post-metadata">

**Author:** ![Modeler3D](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/modeler3d/32/486828_2.png) [@Modeler3D](https://discourse.mcneel.com/u/Modeler3D)\
**Post date:** [July 9, 2020, 5:54pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/19 "2020-07-09T17:54:18Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [July 9, 2020, 7:31pm UTC](https://discourse.mcneel.com/t/python-right-now/105356/20 "2020-07-09T19:31:54Z")

</div>

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:

> <https://stackoverflow.com/questions/15091510/what-does-rc-for-function-return-values-mean>

[Next page](https://discourse.mcneel.com/t/python-right-now/105356.md?page=2)
