Blender Python Api

  1. Blender Python Api Pdf
  2. Blend Api
Blender

Blender Python Api Pdf

File Selection With Python

To add custom mesh to the scene through the Blender Python API we need to do the following: Open the “Text Editor” window. Import the main Blender Python API module. Rendering a cube as png file using Blender's Python API. Create a UV Sphere / Object in Blender from Python. How to make cube? Python: different final location after setting location in edit mode vs object mode. Execute operators from Python at start up.

I write this because I couldn’t easily find a way to create a window in Blender where I can select a file and then use that file. This creates an easy way to open a file, and it works out of the box; copy and paste the code into Blender and run it. As a side note, after searching for quite a while, this code was found on the Blender documentation, tucked away in its far corners.

An Explanation of The Code

This code is very minimal, and could be condensed even more. What it will do is bring up a file selection window. You are then able to browse though folders and select a file and then you can press the button once you get the file you want.

This script doesn’t actually do anything with that file, but what ever you want the script to do with have to be coded in the execute() function.

There are three variables set up that are later referenced in the draw() function. These variables help create the menu on the side of the window. With this, you can create options for the user to provide and affect what the script does with the file.

Download

The draw() function places these objects on rows and columns. Every time you use the col.prop() function, the next time you use it, that value will be placed on the next column. (actually, these names are backwards) and every time you use the row.prop() it will add another variable to that same row.

To access the filename to actually open the file with python, it would be, in this example, self.filename, and likewise, to access the other variables, you would use self.my_float

Blend Api

Body_class. Well that is about it for basics on creating a file selector with Blender 2.59

Comments are closed.