diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-10 18:28:13 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-10 18:28:13 +0400 |
commit | e883de2739d789f84a764875c45943d20bc2fe99 (patch) | |
tree | 86c24626956bf171736bc2806e38767017b97a7e /doc/python_api | |
parent | bdd4aa27b0747bf7bc4af7e23a79b3fbdd3ee5b0 (diff) |
spelling corrections from Philippe Casteleyn
Diffstat (limited to 'doc/python_api')
-rw-r--r-- | doc/python_api/rst/info_gotcha.rst | 28 | ||||
-rw-r--r-- | doc/python_api/rst/info_tips_and_tricks.rst | 21 |
2 files changed, 24 insertions, 25 deletions
diff --git a/doc/python_api/rst/info_gotcha.rst b/doc/python_api/rst/info_gotcha.rst index c97fc3ab427..47dd04853bd 100644 --- a/doc/python_api/rst/info_gotcha.rst +++ b/doc/python_api/rst/info_gotcha.rst @@ -1,6 +1,6 @@ -******** -Gotcha's -******** +******* +Gotchas +******* This document attempts to help you work with the Blender API in areas that can be troublesome and avoid practices that are known to give instability. @@ -32,12 +32,12 @@ Which raises the question as to what the correct context might be? Typically operators check for the active area type, a selection or active object they can operate on, but some operators are more picky about when they run. -In most cases you can figure out what context an operator needs simply be seeing how its used in Blender and thinking about what it does. +In most cases you can figure out what context an operator needs simply be seeing how it's used in Blender and thinking about what it does. Unfortunately if you're still stuck - the only way to **really** know whats going on is to read the source code for the poll function and see what its checking. -For python operators its not so hard to find the source since its included with with Blender and the source file/line is included in the operator reference docs. +For python operators it's not so hard to find the source since it's included with Blender and the source file/line is included in the operator reference docs. Downloading and searching the C code isn't so simple, especially if you're not familiar with the C language but by searching the operator name or description you should be able to find the poll function with no knowledge of C. @@ -74,7 +74,7 @@ Sometimes you want to modify values from python and immediately access the updat Once changing the objects :class:`bpy.types.Object.location` you may want to access its transformation right after from :class:`bpy.types.Object.matrix_world`, but this doesn't work as you might expect. -Consider the calculations that might go into working out the objects final transformation, this includes: +Consider the calculations that might go into working out the object's final transformation, this includes: * animation function curves. * drivers and their pythons expressions. @@ -106,7 +106,7 @@ Modal operators execute on user input or setup their own timers to run frequentl Transform, Painting, Fly-Mode and File-Select are example of a modal operators. -Writing modal operators takes more effort then a simple ``for`` loop that happens to redraw but is more flexible and integrates better with Blenders design. +Writing modal operators takes more effort than a simple ``for`` loop that happens to redraw but is more flexible and integrates better with Blenders design. **Ok, Ok! I still want to draw from python** @@ -129,7 +129,7 @@ This is different to **numpy** which is row-major which matches what you would e I can't edit the mesh in edit-mode! =================================== -Blenders EditMesh is an internal data structure (not saved and not exposed to python), this gives the main annoyance that you need to exit edit-mode to edit the mesh from python. +Blender's EditMesh is an internal data structure (not saved and not exposed to python), this gives the main annoyance that you need to exit edit-mode to edit the mesh from python. The reason we have not made much attempt to fix this yet is because we will likely move to BMesh mesh API eventually, so any work on the API now will be wasted effort. @@ -226,13 +226,13 @@ This is mainly an issue with editmode since pose data can be manipulated without Unicode Problems ================ -Python supports many different encpdings so there is nothing stopping you from writing a script in latin1 or iso-8859-15. +Python supports many different encodings so there is nothing stopping you from writing a script in latin1 or iso-8859-15. See `pep-0263 <http://www.python.org/dev/peps/pep-0263/>`_ -However this complicates things for the python api because blend files themselves dont have an encoding. +However this complicates things for the python api because blend files themselves don't have an encoding. -To simplify the problem for python integration and script authors we have decieded all strings in blend files **must** be UTF-8 or ASCII compatible. +To simplify the problem for python integration and script authors we have decided all strings in blend files **must** be UTF-8 or ASCII compatible. This means assigning strings with different encodings to an object names for instance will raise an error. @@ -331,13 +331,13 @@ This an example of a timer which runs many times a second and moves the default my_timer() -Use cases like the one above which leave the thread running once the script finishes may seem to work for a while but end up causing random crashes or errors in Blenders own drawing code. +Use cases like the one above which leave the thread running once the script finishes may seem to work for a while but end up causing random crashes or errors in Blender's own drawing code. -So far no work has gone into making Blenders python integration thread safe, so until its properly supported, best not make use of this. +So far, no work has gone into making Blender's python integration thread safe, so until its properly supported, best not make use of this. .. note:: - Pythons threads only allow co-currency and wont speed up you're scripts on multi-processor systems, the ``subprocess`` and ``multiprocess`` modules can be used with blender and make use of multiple CPU's too. + Pythons threads only allow co-currency and won't speed up your scripts on multi-processor systems, the ``subprocess`` and ``multiprocess`` modules can be used with blender and make use of multiple CPU's too. Help! My script crashes Blender diff --git a/doc/python_api/rst/info_tips_and_tricks.rst b/doc/python_api/rst/info_tips_and_tricks.rst index bd3ed196193..2bcb1e74c84 100644 --- a/doc/python_api/rst/info_tips_and_tricks.rst +++ b/doc/python_api/rst/info_tips_and_tricks.rst @@ -10,13 +10,13 @@ Some of these are just python features that scripters may not have thought to us Use The Terminal ================ -When writing python scripts, its useful to have a terminal open, this is not the built-in python console but a terminal application which is used to start blender. +When writing python scripts, it's useful to have a terminal open, this is not the built-in python console but a terminal application which is used to start blender. There are 3 main uses for the terminal, these are: -* You can see the output of `print()` as you're script runs, which is useful to view debug info. +* You can see the output of ``print()`` as you're script runs, which is useful to view debug info. -* The error trace-back is printed in full to the terminal which wont always generate an error popup in blenders user interface (depending on how the script is executed). +* The error trace-back is printed in full to the terminal which won't always generate an error popup in blender's user interface (depending on how the script is executed). * If the script runs for too long or you accidentally enter an infinite loop, Ctrl+C in the terminal (Ctrl+Break on Windows) will quit the script early. @@ -69,9 +69,9 @@ This example shows loading a script in as a module and executing a module functi myscript.main() -Notice that the script is reloaded every time, this forces use of the modified version otherwise the cached one in `sys.modules` would be used until blender was restarted. +Notice that the script is reloaded every time, this forces use of the modified version, otherwise the cached one in ``sys.modules`` would be used until blender was restarted. -The important difference between this and executing the script directly is it has to call a function in the module, in this case `main()` but it can be any function, an advantage with this is you can pass arguments to the function from this small script which is often useful for testing different settings quickly. +The important difference between this and executing the script directly is it has to call a function in the module, in this case ``main()`` but it can be any function, an advantage with this is you can pass arguments to the function from this small script which is often useful for testing different settings quickly. The other issue with this is the script has to be in pythons module search path. While this is not best practice - for testing you can extend the search path, this example adds the current blend files directory to the search path, then loads the script as a module. @@ -113,7 +113,7 @@ You might want to run this with a blend file so the script has some data to oper .. note:: - Depending on you're setup you might have to enter the full path to the blender executable. + Depending on your setup you might have to enter the full path to the blender executable. Once the script is running properly in background mode, you'll want to check the output of the script, this depends completely on the task at hand however here are some suggestions. @@ -131,7 +131,7 @@ This can take a little time to setup, but it can be well worth the effort to red Use External Tools ================== -When there are no readily available python modules to perform specific tasks its worth keeping in mind you may be able to have python execute an external command on you're data and read the result back in. +When there are no readily available python modules to perform specific tasks it's worth keeping in mind you may be able to have python execute an external command on you're data and read the result back in. Using external programs adds an extra dependency and may limit who can use the script but to quickly setup you're own custom pipeline or writing one-off scripts this can be handy. @@ -184,7 +184,7 @@ The next example is an equivalent single line version of the script above which __import__('code').interact(local={k: v for ns in (globals(), locals()) for k, v in ns.items()}) -`code.interact` can be added at any line in the script and will pause the script an launch an interactive interpreter in the terminal, when you're done you can quit the interpreter and the script will continue execution. +``code.interact`` can be added at any line in the script and will pause the script an launch an interactive interpreter in the terminal, when you're done you can quit the interpreter and the script will continue execution. Admittedly this highlights the lack of any python debugging support built into blender, but its still handy to know. @@ -201,7 +201,7 @@ Advanced Blender as a module ------------------- -From a python perspective its nicer to have everything as an extension which lets the python script combine many components. +From a python perspective it's nicer to have everything as an extension which lets the python script combine many components. Advantages include: @@ -220,9 +220,8 @@ For instructions on building see `Building blender as a python module <http://wi Python Safety (Build Option) ---------------------------- -Since its possible to accessed data which has been removed (see Gotcha's), this can be a hard to track down the cause of crashes. +Since it's possible to access data which has been removed (see Gotcha's), this can be hard to track down the cause of crashes. To raise python exceptions on accessing freed data (rather then crashing), enable the CMake build option WITH_PYTHON_SAFETY. This enables data tracking which makes data access about 2x slower which is why the option is not enabled in release builds. - |