After introducing himself and this training course, Sybren shows how to start scripting Blender.
- Computers are stupid
- Using the Python console
- Copying stuff from Blender's user interface
- Changing properties of objects
- Sources of information
Links from the video
- Blender's Python API documentation. This link is for daily builds, so it may be for a newer version of Blender than you're currently using. If you want the documentation for your version of Blender, go to Help → Python API Reference in Blender itself.
- Python Standard Library. Here you can find lots of information about Python itself.
Slides are only visible to Blender Cloud susbcribers
Join to comment publicly.
For those using it for 2.81, UV Sphere now uses the radius key instead of size
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.1, location=(1, 1, 1))
@mclifeisagame Thank you
Using Blender version 2.82 out of the box the python code doesn't show, I had to tick Python Tooltips in menu Edit > Preferences > Interface
*@Neil Brown* Thanks.
Copy paste while hovering on command is handy indeed. Cool~
Really great, i also love that you put the slides!, it makes easy to go back and check stuff for reference!, good job sir!
You made me buy a cloud account. Grrrrrr Sybren!
Autocomplete hotkey is TAB in Blender 2.8+
at 4.20: auto-completion now uses
control space(in B2.90 - not sure about B2.8)
I just love this series of video. It's just technical enough not to be boring and still the examples are simple enough to be understandable. Great job. I'm already using all that in my latest project. I'm Done with monkey business !
This is so excellent! Great delivery and graphics. Already worth my monthly subscription. More tutorials like this are always welcome. Thank you.
Transcript please. (no subtitle)
I get this error:
>>> bpy.data.objects("Cube").location.x Traceback (most recent call last): File "<blender_console>", line 1, in <module> TypeError: 'bpy_prop_collection' object is not callable
>>> bpy.data.objects("Cube").location Traceback (most recent call last): File "<blender_console>", line 1, in <module> TypeError: 'bpy_prop_collection' object is not callable
what am i missing? Blender 2.79b MAC
@Björn Strandberg: You're writing a function call
objects(...)instead of trying to index a collection
objects[...]-- note the use of parentheses for the former, and brackets for the latter.
Thanks a bunch!@Sybren A. Stüvel:
Should all of this (and the rest of this course) apply to Blender 2.8 Beta (2019-03-03)? Or should I wait for the official release?
*@Arnar Ómarsson* Much of these techniques will work on 2.8 beta, but there have been significant API changes. With that link you should be able to get quite far, though. Soon I'll start preparing to update things for Blender 2.80; not sure in which form or when that will be available on the Cloud though.
i am copying exactly like you. and i get an IndentationError: unexpected indent
*@Yule Mayevsky* Python is whitespace-sensitive, so make sure that the indentation is correct and that you're not mixing tabs and spaces.
Very nice indeed. Especially copying from Blender into the search of (Api)the documemtation, is what I did not know , a feature I will use probably a lot.
And congratulations Sybren to your way to giving lessons: Introduction what you will talk about, the talk, AND a recapulation of what has been shown. Great!
Thank you so very much for this course, Mr. Stuvel.
I have blender 2.9.01. is this course something I can do with it?
@jamesrossbond Of course! Apart from a few minor things, Blender still works the same.
at around 4 minutes, manipulating the scale: is it correct that scale multiplication is always done with respect to the original object? in other words, with this example command
bpy.data.objects['Cube'].scale = (0.5, 0.3, 0.2)will it always make the cube the same size, rather than shrinking it from whatever size it is at the moment of executing the command?
@Julian Darley Yup, the scale is always relative to the original size of the object.
at 6.17, in the Help Menu one can see an Operator Cheat Sheet. clicking on it seems to do nothing, but in fact, a text file has been created and it can be viewed by selecting it in the Text Editor window under the text dropdown (see the text doc icon). if you keep clicking it (as i did before discovering what was happening), you will create more and more copies of the cheat sheet.
It seems in more recent versions of blender when you hover over something and press control-c you are copying that fields value and not the the python path. Is there a new hotkey?
@Troy Carpenter for editable fields, use ctrl+shift+c to get the data path.
Great series and would like to your vscode integation with blender. Maybe some bender python file structure.I want to write scripts that use other 3rd party modules and output to blender for visuals ( web scrap data then blender to give visuals). Also using python to create node configurations. These are things that could make a new training series.
copy and paste doesn't work for me. I'm using Blender 2.78c 64 bit in Ubuntu 16.04. Any idea why?
@johantri: What are you doing exactly? Which buttons are you pressing? Where is your mouse cursor when you press them?
Hi Sybren. I've been trying to create a selection box with a file browser and I've had no luck as of yet. I know it's a little more advanced, but would you mind pointing me in the right direction?
@Pete Robie: The importance here is to think from the data perspective, and not from the GUI perspective. If you want to have a file selector, the property to store the selected file should have
subtype='FILE_PATH'. Blender will draw an appropriate interface for you then.
@Sybren A. Stüvel: Thank you.