Since you are interested only in 3D models and not in lights or camera models, you need to check if the object is of type mesh (line 2). The first thing you need to do is loop through all the objects in the scene (see line 1 below). Now that you understand the Blender API, let's write a script which will loop through every object, get its name and print out vertex positions, normals and U-V coordinates to the terminal.
#BEST PLACE TO GET 3D BLENDER MODELS CODE#
In code this looks like this: #Obtaining the coordinate of a vertex of an objectīpy. Step 6. In the same manner, the vertices of the object can be found by going into the datablocks subtree and finding that this data is found under: i.e., to get the name of an object in the datablock, you had to click on Scene, then on Objects and then on the Name field. The path that you use in datablocks, is essentially the same path that you would use to access the name through the API. To access the Datablocks, locate the right-hand section of Blender and click on All Scenes and select Datablocks I was very confused with this API until I came across the Datablocks view.
The Blender API can be a bit confusing at first. Let's print the vertex position to the terminal: import bpy For example, if you want to get the first vertex position of the object, you would access it as follows: #Accessing the first vertex position of the object.īpy. Now, if you want to access the object's data, you would need to access its data attributes. If you want to get the name of the object, you would access its name as follows: #accessing the name of an object in the sceneĪs a matter of a test, let's print out the name of your object to the terminal: import bpy If you want to access its first object in the scene, you would access it as follows: #accessing an object in blender For example if you want to access its scene, you would access its context and then its scene attribute: #accessing a scene in blender To do any of these operations you need to know the attributes/operators used in Blender.Įverything in Blender can be access through its context. You can get the name of a 3D model, orientation, position, etc. Let's do a simple test where you print out the name and vertices of an object.īlender allows you to control 3D models through its API. Let's get confortable using the Blender API.