4
$\begingroup$

I'm looking at an export script and I see where it extracts the various 3d properties from an object named "me" like these 3 lines:

me = bpy.context.object.data #EDIT: This is what "me" is, I think
me_verts = me.vertices[:]
materials = me.materials[:]
faceuv = len(me.uv_textures) > 0

Which it goes on to format and write to a file. Where can I find a list of all the things I can access like this? I found the python API but I haven't found this specifically.

$\endgroup$
6
$\begingroup$
  • The export and import scripts are indeed an excellent form of documentation.
  • There is a massive amount of documentation. This includes a quickstart and API overview. More importantly it has a good search box (warning: avoid including parenthesis when searching functions).
  • Interactively you can use the python console to investigate which properties are available on a given reference. It has a ctrl+space auto-complete (auto reveal).

in the console for instance

>>> obj = bpy.context.object   # the current active object
>>> obj = bpy.data.objects['Cube']   # object specified by name
>>> obj.

if you type obj. and hit ctrl+space you'll see all the attributes of the object at that level. This list is long, and you can scroll the sidebar

enter image description here

As you state me = obj.data, the me named variable is just a convention, it could be called whatever, but it's handy to stick to the convention.

obj.data.<ctrl+space> looks like

enter image description here

If you want to see information about the mesh you might do

# get coordinates of 1st vertex (index=0)
>>> obj.data.vertices[0].co   

# indices that make up the first polygon in the mesh
>>> obj.data.polygons[0].vertices[:]  

enter image description here

Note that the ctrl+space feature will show all attributes starting with the letter v if you do obj.data.v<ctrl+space> like this:

enter image description here

This becomes useful once you get a mental picture of the API, it can speed up navigation big time.

$\endgroup$
  • $\begingroup$ The ctrl-space thing was immensely helpful, having the exact names will make finding documentation so much easier. $\endgroup$ – gunfulker Apr 29 '15 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.