[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43810] trunk/blender/doc/python_api/rst/ info_quickstart.rst: added note in docs about not beaing able to create new data by calling the class direct .

Campbell Barton ideasman42 at gmail.com
Tue Jan 31 23:37:45 CET 2012


Revision: 43810
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43810
Author:   campbellbarton
Date:     2012-01-31 22:37:36 +0000 (Tue, 31 Jan 2012)
Log Message:
-----------
added note in docs about not beaing able to create new data by calling the class direct.

Modified Paths:
--------------
    trunk/blender/doc/python_api/rst/info_quickstart.rst

Modified: trunk/blender/doc/python_api/rst/info_quickstart.rst
===================================================================
--- trunk/blender/doc/python_api/rst/info_quickstart.rst	2012-01-31 22:12:33 UTC (rev 43809)
+++ trunk/blender/doc/python_api/rst/info_quickstart.rst	2012-01-31 22:37:36 UTC (rev 43810)
@@ -123,6 +123,29 @@
    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 "<blender_console>", line 1, in <module>
+   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_struct, Mesh("MyMesh.001")>
+
+   >>> bpy.data.meshes.remove(mesh)
+
+
 Custom Properties
 ^^^^^^^^^^^^^^^^^
 



More information about the Bf-blender-cvs mailing list