~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/python/api2_2x/doc/Blender.py

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
# The module files in this folder are used to create the API documentation.
4
4
# Doc system used: epydoc - http://epydoc.sf.net
5
 
# command line:
6
 
 
7
 
# epydoc -o BPY_API_230 --url "http://www.blender.org" -t Blender.py \
 
5
# pseudo command line (check the epy_docgen.sh file):
 
6
# epydoc -o BPY_API_23x --url "http://www.blender.org" -t Blender.py \
8
7
# -n "Blender" --no-private --no-frames Blender.py \
9
 
# Types.py Scene.py Object.py NMesh.py Material.py Camera.py Lamp.py \
10
 
# Armature.py Metaball.py Effect.py Curve.py Ipo.py World.py BGL.py Window.py \
11
 
# Draw.py Image.py Text.py Lattice.py Texture.py Registry.py Sys.py Mathutils.py
 
8
# Types.py Scene.py Object.py [ ... etc]
12
9
 
13
10
"""
14
11
The main Blender module.
15
12
 
16
 
The Blender Python API Reference
17
 
================================
18
 
 
19
 
 Submodules:
20
 
 -----------
21
 
 
22
 
  - L{Armature}
23
 
     - L{Bone}
24
 
     - L{NLA} (new)
25
 
  - L{BGL}
26
 
  - L{Camera}
27
 
  - L{Curve}
28
 
  - L{Draw}
29
 
  - L{Effect}
30
 
  - L{Image}
31
 
  - L{Ipo}
32
 
  - L{Lamp}
33
 
  - L{Lattice}
34
 
  - L{Library} (new)
35
 
  - L{Material}
36
 
  - L{Mathutils} (new)
37
 
  - L{Metaball}
38
 
  - L{NMesh}
39
 
  - L{Noise} (new)
40
 
  - L{Object}
41
 
  - L{Registry}
42
 
  - L{Scene}
43
 
     - L{Render} (new)
44
 
  - L{Text}
45
 
  - L{Texture}
46
 
  - L{Types}
47
 
  - L{Window}
48
 
  - L{World}
49
 
  - L{sys<Sys>} (added time function)
50
 
 
51
 
 Introduction:
52
 
 -------------
53
 
 
54
 
 This Reference documents the Blender Python API, a growing collection of
55
 
 Python modules (libs) that give access to part of the program's internal data
56
 
 and functions.
57
 
 
58
 
 Through scripting, Blender can be extended in realtime.  Possibilities range
59
 
 from simple functionality to importers / exporters and even more complex
60
 
 "applications".  Blender scripts are written in
61
 
 U{Python <www.python.org>}, an impressive high level, multi-paradigm,
62
 
 open-source language.
63
 
 
64
 
@author: The Blender Python Team
65
 
@requires: Blender 2.33 or newer.
66
 
@version: 2.33
67
 
@see: U{www.blender.org<http://www.blender.org>}
68
 
@see: U{projects.blender.org<http://projects.blender.org>}
69
 
@see: U{www.python.org<http://www.python.org>}
70
 
@see: U{www.python.org/doc<http://www.python.org/doc>}
 
13
B{New}: L{Run}, L{UpdateMenus}, new options to L{Get}, L{ShowHelp},
 
14
L{SpaceHandlers} dictionary.
 
15
 
 
16
Blender
 
17
=======
 
18
 
 
19
@type bylink: bool
 
20
@var bylink: True if the current script is being executed as a script link.
 
21
@type link: Blender Object or None; integer (space handlers)
 
22
@var link: for normal script links, 'link' points to the linked Object (can be
 
23
    a scene, object (mesh, camera, lamp), material or
 
24
    world).  For space handler script links, 'link' is an integer from the
 
25
    Blender.L{SpaceHandlers} dictionary.  For script not running as script
 
26
    links, 'link' is None.
 
27
@type event: string or int
 
28
@var event: this has three possible uses: script link type or events callback
 
29
    ascii value:
 
30
      - for normal script links it is a string representing the link type
 
31
        (OnLoad, FrameChanged, Redraw, etc.).
 
32
      - for EVENT space handler script links it is the passed event.
 
33
      - for normal L{GUI<Draw.Register>} scripts I{during the events callback},
 
34
        it holds the ascii value of the current event, if it is a valid one.
 
35
        Users interested in this should also check the builtin 'ord' and 'chr'
 
36
        Python functions. 
 
37
@type mode: string
 
38
@var mode: Blender's current mode:
 
39
    - 'interactive': normal mode, with an open window answering to user input;
 
40
    - 'background': Blender was started as 'C{blender -b <blender file>}' and
 
41
      will exit as soon as it finishes rendering or executing a script
 
42
      (ex: 'C{blender -b <blender file> -P <script>}').  Try 'C{blender -h}'
 
43
      for more detailed informations.
 
44
@type SpaceHandlers: constant dictionary
 
45
@var SpaceHandlers: dictionary with space handler types.
 
46
    - VIEW3D_EVENT;
 
47
    - VIEW3D_DRAW.
71
48
"""
72
49
 
73
50
def Set (request, data):
85
62
  Retrieve settings from Blender.
86
63
  @type request: string
87
64
  @param request: The setting data to be returned:
88
 
      - 'curframe': the current animation frame
89
 
      - 'curtime' : the current animation time
90
 
      - 'staframe': the start frame of the animation
91
 
      - 'endframe': the end frame of the animation
92
 
      - 'filename': the name of the last file read or written
93
 
      - 'version' : the Blender version number
94
 
  @return: The requested data.
 
65
      - 'curframe': the current animation frame.
 
66
      - 'curtime' : the current animation time.
 
67
      - 'staframe': the start frame of the animation.
 
68
      - 'endframe': the end frame of the animation.
 
69
      - 'filename': the name of the last file read or written.
 
70
      - 'homedir':  Blender's home dir.
 
71
      - 'datadir' : the path to the dir where scripts should store and
 
72
            retrieve their data files, including saved configuration (can
 
73
            be None, if not found).
 
74
      - 'udatadir': the path to the user defined data dir.  This may not be
 
75
            available (is None if not found), but users that define uscriptsdir
 
76
            have a place for their own scripts and script data that won't be
 
77
            erased when a new version of Blender is installed.  For this reason
 
78
            we recommend scripts check this dir first and use it, if available.
 
79
      - 'scriptsdir': the path to the main dir where scripts are stored.
 
80
      - 'uscriptsdir': the path to the user defined dir for scripts. (*)
 
81
      - 'yfexportdir': the path to the user defined dir for yafray export. (*)
 
82
      - 'fontsdir': the path to the user defined dir for fonts. (*)
 
83
      - 'texturesdir': the path to the user defined dir for textures. (*)
 
84
      - 'texpluginsdir': the path to the user defined dir for texture plugins. (*)
 
85
      - 'seqpluginsdir': the path to the user defined dir for sequence plugins. (*)
 
86
      - 'renderdir': the path to the user defined dir for render output. (*)
 
87
      - 'soundsdir': the path to the user defined dir for sound files. (*)
 
88
      - 'tempdir': the path to the user defined dir for storage of Blender
 
89
            temporary files. (*)
 
90
      - 'version' : the Blender version number.
 
91
  @note: (*) these can be set in Blender at the User Preferences window -> File
 
92
      Paths tab.
 
93
  @warn: this function returns None for requested dir paths that have not been
 
94
      set or do not exist in the user's file system.
 
95
  @return: The requested data or None if not found.
95
96
  """
96
97
 
97
98
def Redraw ():
99
100
  Redraw all 3D windows.
100
101
  """
101
102
 
102
 
def ReleaseGlobalDict (bool = None):
103
 
  """
104
 
  @depreciated: this function doesn't work anymore and will be removed. 
105
 
      Look at the L{Registry} submodule for a better alternative.
 
103
def Load (filename = None):
 
104
  """
 
105
  Load a Blender .blend file or any of the other supported file formats.
 
106
 
 
107
  Supported formats:
 
108
    - Blender's .blend;
 
109
    - DXF;
 
110
    - Open Inventor 1.0 ASCII;
 
111
    - Radiogour;
 
112
    - STL;
 
113
    - Videoscape;
 
114
    - VRML 1.0 asc.
 
115
 
 
116
  @type filename: string
 
117
  @param filename: the pathname to the desired file.  If 'filename'
 
118
      isn't given or if it contains the substring '.B.blend', the default
 
119
      .B.blend file is loaded.
 
120
 
 
121
  @warn: loading a new .blend file removes the current data in Blender.  For
 
122
     safety, this function saves the current data as an autosave file in
 
123
     the temporary dir used by Blender before loading a new Blender file.
 
124
  @warn: after a call to Load(blendfile), current data in Blender is lost,
 
125
     including the Python dictionaries.  Any posterior references in the
 
126
     script to previously defined data will generate a NameError.  So it's
 
127
     better to put Blender.Load as the last executed command in the script,
 
128
     when this function is used to open .blend files.
 
129
  @warn: if in edit mode, this function leaves it, since Blender itself
 
130
     requires that.
 
131
  """
 
132
 
 
133
def Save (filename, overwrite = 0):
 
134
  """
 
135
  Save a Blender .blend file with the current program data or export to
 
136
  one of the builtin file formats.
 
137
  
 
138
  Supported formats:
 
139
    - Blender (.blend);
 
140
    - DXF (.dxf);
 
141
    - STL (.stl);
 
142
    - Videoscape (.obj);
 
143
    - VRML 1.0 (.wrl).
 
144
 
 
145
  @type filename: string
 
146
  @param filename: the filename for the file to be written.  It must have one
 
147
      of the supported extensions or an error will be returned.
 
148
  @type overwrite: int (bool)
 
149
  @param overwrite: if non-zero, file 'filename' will be overwritten if it
 
150
      already exists (can be checked with L{Blender.sys.exists<Sys.exists>}.
 
151
      By default existing files are not overwritten (an error is returned).
 
152
 
 
153
  @note: The substring ".B.blend" is not accepted inside 'filename'.
 
154
  @note: DXF, STL and Videoscape export only B{selected} meshes.
 
155
  """
 
156
 
 
157
def Run (script):
 
158
  """
 
159
  Execute the given script.
 
160
  @type script: string
 
161
  @param script: the name of an available Blender Text (use L{Text.Get}() to
 
162
      get a complete list) or the full pathname to a Python script file in the
 
163
      system.
 
164
  @note: the script is executed in its own context -- with its own global
 
165
      dictionary -- as if it had been executed from the Text Editor or chosen
 
166
      from a menu.
 
167
  """
 
168
 
 
169
def ShowHelp (script):
 
170
  """
 
171
  Show help for the given script.  This is a time-saver ("code-saver") for
 
172
  scripts that need to feature a 'help' button in their GUI's or a 'help'
 
173
  submenu option.  With proper documentation strings, calling this function is
 
174
  enough to present a screen with help information plus link and email buttons.
 
175
  @type script: string
 
176
  @param script: the filename of a registered Python script.
 
177
  @note: this function uses L{Run} and the "Scripts Help Browser" script.  This
 
178
     means that it expects proper doc strings in the script to be able to show
 
179
     help for it (otherwise it offers to load the script source code as text).
 
180
     The necessary information about doc strings is in the
 
181
     L{Intro page<API_intro>} of this API Reference documentation you're
 
182
     reading.
 
183
  @note: 'script' doesn't need to be a full path name: "filename.py" is enough.
 
184
     Note, though, that this function only works for properly registered
 
185
     scripts (those that appear in menus).
 
186
  """
 
187
 
 
188
def UpdateMenus ():
 
189
  """
 
190
  Update the menus that list registered scripts.  This will scan the default
 
191
  and user defined (if available) folder(s) for scripts that have registration
 
192
  data and will make them accessible via menus.
 
193
  @note: only scripts that save other new scripts in the default or user
 
194
    defined folders need to call this function.
 
195
  """
 
196
 
 
197
def Quit ():
 
198
  """
 
199
  Exit from Blender immediately.
 
200
  @warn: the use of this function should obviously be avoided, it is available
 
201
     because there are some cases where it can be useful, like in automated
 
202
     tests.  For safety, a "quit.blend" file is saved (normal Blender behavior
 
203
     upon exiting) when this function is called, so the data in Blender isn't
 
204
     lost.
106
205
  """