From 4fd4a2e7b92c68c3770fe2d0bbfa4e6a1cef9d77 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 Jan 2012 22:37:36 +0000 Subject: [PATCH] added note in docs about not beaing able to create new data by calling the class direct. --- doc/python_api/rst/info_quickstart.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/python_api/rst/info_quickstart.rst b/doc/python_api/rst/info_quickstart.rst index b37b7558770..19ec8059aca 100644 --- a/doc/python_api/rst/info_quickstart.rst +++ b/doc/python_api/rst/info_quickstart.rst @@ -123,6 +123,29 @@ Example of a data path that can be quickly found via the console: 1.0 +Data Creation/Removal +^^^^^^^^^^^^^^^^^^^^^ + +Those of you familiar with other python api's may be surprised that new datablocks in the bpy api can't be created by calling the class: + + >>> bpy.types.Mesh() + Traceback (most recent call last): + File "", line 1, in + TypeError: bpy_struct.__new__(type): expected a single argument + + +This is an intentional part of the API design. +The blender/python api can't create blender data that exists outside the main blender database (accessed through bpy.data), because this data is managed by blender (save/load/undo/append... etc). + +Data is added and removed via methods on the collections in bpy.data, eg: + + >>> mesh = bpy.data.meshes.new(name="MyMesh") + >>> print(mesh) + + + >>> bpy.data.meshes.remove(mesh) + + Custom Properties ^^^^^^^^^^^^^^^^^