The goal of this module is to introduce all of the basics of controlling blender through python code. Patrick will introduce the many ways Blender makes it easy to write your own code without having any experience with blender's API. You will first learn how to run single-lined python commands and manipulate objects and information, followed by exploring how object information is used and stored in blender.
- [Instructor] The goal of this chapter is to learn how you can control Blender's user interface using single line pipe on commands, but the first step, of course, is to download Blender itself. If you navigate to blender.org, you'll be presented the home screen where you can then see the current version of Blender. In this case, 2.77a. We'll be using this version for the duration of the course. Any more recent versions, as well as older versions back to 2.5, should also work. From this screen, you can then select the according operating system and download you prefer.
In my case, I generally like the dot zip, as opposed to the installers because the portable version can be more convenient to move around, especially when you have more than one version of Blender on your machine. Once the download has completed, navigate to the download folder. Then I'm going to extract the download. Then I'm going to move it to my applications folder. From there, I can double-click Blender to open it. You may need to accept a warning to say, okay it was downloaded from the internet.
And now we are presented the default Blender screen. The next step is to make sure that we are able to see the output console, so that whenever we want Python Scripts, we can see things like print statements as well error messages. If you're on a Windows machine, this can be accomplished by going to the header window drop down, then selecting an option that will exist that says toggle system console. If you're on a MAC machine, simply go back to the application. Right-click to show package contents.
Navigate to contents, MAC OS, and then select the Blender executable. Then, right-click make alias and then you can move this alias to a convenient location, such as on your desktop. I'm gonna then rename this to say Blender with console. The purpose of creating this alias is we don't have to navigate into the application itself every single time. If you now close out of Blender, if you then double-click the alias we created, you should notice two things happen.
First, a console window shows up with some start up script information which Blender uses when it launches. Then we should see the default screen. For the most part, you can keep this console window in the background as you use just Blender normally, but if you need to, we can go back to the screen to see print and error statements as necessary. You are now ready to start scripting with Blender.
- Controlling Blender with code
- Exploring the bpy library
- Creating Blender operators and properties
- Writing scripts
- Auto running scripts
- Drawing interface elements such as panels and menus
- Building a custom add-on