Films Training Blog
Pipeline and Tools Characters
Pipeline and Tools Characters
search Login Join
favorite

Development Fund

Support Blender Core Development with a monthly contribution.

theaters

Blender Studio

The creators who share. Access production content and knowledge from the Open Movies.

code

Blender Developer Blog

Latest news and updates on Blender development.

people

Get Involved

Join the community and help with design, development, docs and more.

bar_chart

Open Data

A platform to collect and display the Blender Benchmark results.

menu_book

Blender Docs

Documentation on Blender's features, tools and API.

Blender Conference

The yearly event that brings together the Blender community in one place.

download

Get Blender

Download the latest Blender version, or try the beta!

Films
Training
Blog
Pipeline and Tools
Characters
Search
Login
Join

Course

Scripting for Artists
feed Course Overview
feed Blender Versions
Videos keyboard_arrow_down
  1. 01

    Introduction & copy-pasting

    Free
  2. 02

    Names & Objects

  3. 03

    Stuff on Lists

  4. 04

    Data Types

  5. 05

    Collections: Mass-Rename of Objects

  6. 06

    Blender Collections

    Free
  7. 07

    For vs. While

    Free
  8. 08

    Your Own Operator

    Free
  9. 09

    From Script to Add-on

    Free
  10. 10

    User Interfaces

    Free
  11. 11

    Custom Properties

    Free
  12. 12

    Asset Linking

    Free
  13. 13

    Roast my Add-on

    Free
  14. 14

    The Roast of Nature Clicker

    Free
  15. 15

    Modal Operators

    Free
  16. 16

    Readability & Understandability

Tech keyboard_arrow_down
  1. 01

    Updating F-Curves

  2. 02

    Render 10,000 OBJ files

  3. 03

    Mass-Rename Bones & Vertex Groups

  4. 04

    Rendering from 'all' angles

Course

Scripting for Artists
feed Blender Versions
Videos keyboard_arrow_down
  1. 01

    Introduction & copy-pasting

    Free
  2. 02

    Names & Objects

  3. 03

    Stuff on Lists

  4. 04

    Data Types

  5. 05

    Collections: Mass-Rename of Objects

  6. 06

    Blender Collections

    Free
  7. 07

    For vs. While

    Free
  8. 08

    Your Own Operator

    Free
  9. 09

    From Script to Add-on

    Free
  10. 10

    User Interfaces

    Free
  11. 11

    Custom Properties

    Free
  12. 12

    Asset Linking

    Free
  13. 13

    Roast my Add-on

    Free
  14. 14

    The Roast of Nature Clicker

    Free
  15. 15

    Modal Operators

    Free
  16. 16

    Readability & Understandability

Tech keyboard_arrow_down
  1. 01

    Updating F-Curves

  2. 02

    Render 10,000 OBJ files

  3. 03

    Mass-Rename Bones & Vertex Groups

  4. 04

    Rendering from 'all' angles

You need to login to view this content

You can join Blender Studio for €11.50/month and get access to all of our training & film content instantly!

Login Join Blender Studio

Videos

Names & Objects

16th August 2017

info License: CC-BY
flag Report Problem

Published by

Sybren A. Stüvel

In this video we see how, in Python, names refer to objects. In this context, an "object" refers to a thing in Python, and not necessarily a Blender object in 3D space. Knowing how names refer to things in memory is an essential part of scripting (and not wearing out your fingers from all the typing).

  • Everything is an Object (in Python)
  • Names refer to Objects
  • Using Blender's Context
  • Digging through names & objects by dotting

The Slides

Slides are only visible to Blender Cloud susbcribers

14 Comments

Join to comment publicly.

Adam Juhasz

23rd August 2017 - 10:22

Wow Sybren! I can't thank you enough! You have special talent for explaining this kind of stuff! I'm a recovering "script avoiding addict" I'm almost sure this course will cure me :D

Steven Goodman

6th August 2021 - 06:51

I disagree that monkey is definitely not named 'Steve'. I think it's 'Suzanne' ....

Takeshi Funahashi

4th September 2017 - 03:17

Hi thanks you offer script tutoriall. it is really useful to learn blender specific operations. then I have one question about context. in blender manuall, it say "all context values are readonly, but may be modified through the data api or by running operators"

but when I try to re-name, by bpy.context.active_object.name = "newmonkey" it could work in blender console. is it exceptional case? or if I can only change location.x etc by context?

Stephen Petersen

4th September 2017 - 10:35

@fun2tax: I did it in 2 lines.

a = bpy.context.active_object

a.name = "newmonkey"

Show more replies

Sybren A. Stüvel

5th September 2017 - 08:36

@fun2tax: That remark only relates to the names in bpy.context themselves. For example, you cannot do bpy.context.active_object = some_ob to make some_ob the active object. Instead, you have to assign to bpy.context.scene.objects.active, since every scene has an active object.

You can still change the name of an object by assigning a value to its name attribute; the fact that that object happens to also be accessible through bpy.context.active_object does not all of a sudden make its name or location attributes read-only.

@Stefan59: it doesn't matter whether you do something in one or two lines. In your case, a is just another name for that particular object. It's the object itself that determines what you can do with it, not the name you assign to it.

Takeshi Funahashi

5th September 2017 - 12:51

@sybren: thanks now I seems understand , bpy.context read only meaning better. and Yes stephan, it actually work for me too. then I though it can be changed by context too.

Christopher Mills

28th February 2022 - 04:05

Very new to Blender scripting. TAB is your Python auto-complete friend. Others new to Blender's way may benefit from knowing this.

Raj Arora

26th August 2017 - 01:12

The autoplay just repeats the first video over and over again. it doesn't go to the next one

Stephen Petersen

26th August 2017 - 23:47

@raj: never has

Roland Gsell

8th November 2017 - 20:33

Hi, thanks for the tutorial!

If I say:

steve = bpy.ops.mesh.primitive_circle_add()

steve will become the string {'FINISHED'}, which might be handy for error handling, but I expected it to be a reference to the created object.

If I want to immediately do something with steve, I can refer to the active object, but what if I want to just remember that specific object for later modifications, I could use these lines:

bpy.ops.mesh.primitive_circle_add()

steve = bpy.context.selected_objects[0]

However, I'd like to know if I could write that in just one line.

Sybren A. Stüvel

9th November 2017 - 15:46

@Roland Gsell: the returned value of an operator will always be of this form, so you can't write what you want in one line. I would also suggest using steve = bpy.context.active_object instead of using selected_objects[0]. If later the active object changes, steve will still point to the circle object you added.

Show more replies

Roland Gsell

9th November 2017 - 17:25

@Dr. Sybren: Thanks! The strange thing is that python autocompleted activ... to active_objects - so I thought there's no single object to work with.

Maybe that's sort of a zsh autocompletion and I'm more the bash-guy ;-) I can't try it out at the moment, my Blender is rendering some stuff...

I love the new version by the way. 100 samples with denoise looks much better than 500 with 2.78..

PlumpMath

3rd February 2018 - 00:44

Transcript please. (no subtitle)

Simonetos The Greek

27th September 2020 - 17:42

Very helpful videos but It would be really better if we had at least English subtitles!!! In a few parts I can't really understand what Mr. Sybren says... Subtitles would be really useful!!!

Blender Studio

The Creators Who Share.

Facebook Logo Twitter Logo YouTube Logo
  • Films
  • Blog
  • Training
Pipeline and Tools
  • Cloud Rig
  • Blender Kitsu
  • Contact Sheet Add-on
  • Blender Purge
  • Blender Cloud Services
Characters
  • Einar
  • Security Bot
  • Huginn
  • Pack Bot
Studio
  • Terms & Conditions
  • Privacy Policy
  • Contact
  • Remixing Music
  • Blender.org
Loading...