Commit Graph

461 Commits

Author SHA1 Message Date
Campbell Barton
c8652b301f pep8 checker, mostly pedantic style changes but also found an error in mesh_utils.mesh_linked_faces() 2011-04-01 02:41:15 +00:00
Campbell Barton
6e5ce953da use 'is None' rather then '== None' as suggested by python docs & mis-spelling. 2011-03-29 04:16:55 +00:00
Martin Poirier
3598882f0e Proper traceback when addons fails AST parsing setp 2011-03-27 20:52:50 +00:00
Campbell Barton
50a06eccff pep8 cleanup 2011-03-27 05:23:14 +00:00
Campbell Barton
7ccfec1ff3 fix (own bug) [#26628] "FCurve/Driver Version Fix" Incorrectly Clobbers Array Indexing
also escape strings properly now.
2011-03-27 03:14:14 +00:00
Joshua Leung
7beca3d142 Bugfixes due to recent RNA renaming:
* Driver F-Curves were not getting fixed by the "FCurve/Driver Version
Fix" tool. This was causing problems such as shapekey drivers from
older (2.56 compatible rigs) failing to run. As well as renaming the
paths for these Driver F-Curves, the "disabled" flags also get cleared
from these drivers so that they can be run again

* "Revive Disabled F-Curves"  operator in Animation Editors can now be
used to revive disabled drivers too.
2011-03-26 23:42:51 +00:00
Campbell Barton
0c03fa78c1 fix [#26601] Python error when use of autocomplete
Was a naming collision with 'keys' python method, reserve keys/items/values/get for python.
Updated animsys_update.py for shapekey data paths.

renamed:
  Particle.hair --> hair_keys
  Particle.keys --> particle_keys
  Key.keys --> key_blocks
  EnumProperty.items --> enum_items
  KeyMap.items --> keymap_items 

noted:
  http://wiki.blender.org/index.php/Dev:2.5/Py/API/Updates#Since_2.56a
2011-03-25 02:12:44 +00:00
Campbell Barton
b510019602 fix for incorrect prints with RNA errors (own fault, CONTAINER_RNA_ID was incorrect) & close keymap file after running. 2011-03-25 01:55:00 +00:00
Campbell Barton
2c4999eccb missed committing this before 2011-03-23 15:14:21 +00:00
Campbell Barton
a2acecc9d2 allow system info operator in background mode. 2011-03-22 11:44:46 +00:00
Campbell Barton
1b80538fea fix [#25688] undocumted functions in pyapi
expose collection function docs.
2011-03-22 04:28:51 +00:00
Campbell Barton
f3686b5885 py/api registration:
move calls to the classes register/unregister function into register_class() / unregister_class() and add docs.

also other minor changes:
- remove face sorting keybinding, was Ctrl+Alt+F, this is quite and obscure feature and face order normally doesn't matter, so access from Face menu is enough.
- add commented out call to mesh.validate() in addon template since its useful to correct incomplete meshes during development.
2011-03-22 01:38:26 +00:00
Campbell Barton
379f55f54c fix for error printing class register error, remove an unneeded check. 2011-03-21 22:17:01 +00:00
Campbell Barton
2e6a02438e move script directories for internal blender scripts.
ui/ --> startup/bl_ui
op/ --> startup/bl_operators

scripts/startup/ is now the only auto-loading script dir which gives some speedup for blender loading too.

~/.blender/2.56/scripts/startup works for auto-loading scripts too.
2011-03-21 12:35:49 +00:00
Campbell Barton
599bd1cbda patch from Martin, call classes register/unregister functions.
Modified to only do one lookup.

from Martin: 
 "Basically, what it does is allow you to add register and unregister class methods to rna types, this way you don't have to rely on module register/unregister methods to setup your types properly (and it makes them easier to move around when reorganizing code and easier to understand what a type does when reading code). This is especially nice for PropertyGroup classes that are added as properties to existing types, you can easily see in their register methods where they are added and removed in their unregister method. Obviously, those two methods are optional, so current code still works fine."
2011-03-21 06:22:09 +00:00
Campbell Barton
e44da6b695 hide addon_utils in bpy.utils & tag/remove unused vars in recent commits. 2011-03-18 20:57:32 +00:00
Campbell Barton
82783cd0cd pep8 edits and remove commented code from last commit. 2011-03-14 23:17:52 +00:00
Campbell Barton
2d1ef275f2 bpy.types.libraries.load sphinx doc & examples (doc system needed some updates).
http://www.blender.org/documentation/blender_python_api_2_56_3/bpy.types.BlendDataLibraries.html#bpy.types.BlendDataLibraries.load
2011-03-14 10:31:50 +00:00
Campbell Barton
bd1c5d48f2 RNA API Rename
'create' was used as prefix and suffix, change dupli list functions to use as suffix, this matches obj.animation_data_create() & obj.animation_data_clear().
 obj.create_dupli_list() --> obj.dupli_list_create()
 obj.free_dupli_list() --> obj.dupli_list_clear()

Don't use 'create' for object to mesh function since other uses of this are for createing data which stays attached, instead use mathutils style naming convention.
  obj.create_mesh() --> obj.to_mesh()
2011-03-14 01:37:18 +00:00
Campbell Barton
8c526e79e3 library loading api.
this is not well suited to RNA so this is a native python api.

This uses:
  bpy.data.libraries.load(filepath, link=False, relative=False)

however the return value needs to use pythons context manager, this means the library loading is confined to a block of code and python cant leave a half loaded library state.


eg, load a single scene we know the name of:
  with bpy.data.libraries.load(filepath) as (data_from, data_to):
      data_to.scenes = ["Scene"]


eg, load all scenes:
  with bpy.data.libraries.load(filepath) as (data_from, data_to):
      data_to.scenes = data_from.scenes


eg, load all objects starting with 'A'
  with bpy.data.libraries.load(filepath) as (data_from, data_to):
      data_to.objects = [name for name in data_from.objects if name.startswith("A")]

As you can see gives 2 objects like 'bpy.data', but containing lists of strings which can be moved from one into another.
2011-03-12 16:06:37 +00:00
Campbell Barton
897c2ede13 py/ui: ensure extensions which add draw functions for menus/headers/panels always get the default operator context, not the one that was last set. 2011-03-09 10:57:56 +00:00
Campbell Barton
c544d3ffb8 Py/Operators: FBX Exporter setting order was still randomized.
Some lines removed recently I thought were are needed were there so classes that use mix-ins keep the argument order.
2011-03-07 08:57:35 +00:00
Campbell Barton
db066592b7 PyAPI: allow subclasses of io_utils.ExportHelper to set when the extension is enforced. 2011-03-07 08:01:38 +00:00
Campbell Barton
2f741e4dde fix for own error [#26310] "Randomize Transform" operator has widgets jumbled
the correct order was being overwritten.
2011-03-03 13:23:40 +00:00
Campbell Barton
21067886aa update for changed exception type 2011-03-02 04:16:57 +00:00
Campbell Barton
5ef65a0a3b build system now exclude config-*, turtledemo when copying system python.
also remove __pycache__ dirs when cleaning (new in python 3.2)
2011-02-28 05:59:44 +00:00
Campbell Barton
e09189cf50 complete lazy loading of py modules to use to a reduced set of pythons modules, gives ~40% speedup on cold & warm start (without netrender).
- use own OrderedDictMini class, pythons collections.OrderedDict is overkill, 179 sloc. replaced with own, 11 lines.
- remove code which stored the class file & line per RNA subclass, this was useful but would raise its own exception every time to generate a stack trace to get the class info so we could use of the class failed to register. the class stores its module & name which can be enough to find where it was defined.
2011-02-28 04:37:24 +00:00
Campbell Barton
fc0c016940 replace import *'s with named imports (using * is convenient for some scripts but considered bad practice by python devs) 2011-02-27 15:25:24 +00:00
Campbell Barton
52f92b4cb1 lazy load modules for more scripts. 2011-02-27 14:16:32 +00:00
Campbell Barton
87acf919a5 lazy load pydoc module. move help() replacement into console code rather then on startup since importing pydoc pulls in lots of other modules too. 2011-02-27 14:08:33 +00:00
Campbell Barton
91e6fd1828 port of function from 2.4x's BPyMesh.py thanks to 'merlin_' on IRC. 2011-02-26 16:13:14 +00:00
Campbell Barton
b25db7c8cb pep8 cleanup 2011-02-25 16:06:14 +00:00
Campbell Barton
2fd60d9719 error in own recent moving addons functions into its own module. addon_utils.reset_all failed. 2011-02-22 22:24:50 +00:00
Campbell Barton
4b859e91cb bugfix/workaround [#25629] Add torus with autmatic edit mode duplicates mesh after >Aling to View.
adding meshes in C does:
 Add Empty Mesh -> Enter Editmode -> Create Mesh

while python does:
 Add Generated Mesh -> Enter Editmode


problem with this is there is no empty undo state for undo-redo to use so it always gave a duplicate mesh on redo-ing.
workaround by adding an empty mesh, do an undo push, and join the generated mesh into the empty one.

this would be fixed if undo stack spanned modes.
2011-02-22 02:47:59 +00:00
Nathan Vegdahl
ea20a27240 Editbone length was still using "normalize()" instead of "normalized()"
for setting length, which was thus failing and erroring out.
2011-02-21 20:26:37 +00:00
Campbell Barton
eee4a62e87 move addon utilities into their own module, these were getting mixed between bpy.utils and space_userpref. 2011-02-21 07:07:44 +00:00
Campbell Barton
54dd0f57cf bug [#26089] editbone.transfrom() seems to mess up bone roll (by more than float precision error)
This is intentional behavior but add options not to transform the bones scale & roll.
2011-02-21 01:29:35 +00:00
Campbell Barton
063a7f217b python api docs & examples for registrable Menu/Panel/Operator/PropertyGroup classes. 2011-02-18 08:47:37 +00:00
Campbell Barton
812f238494 pep8 cleanup and remove unused vars/imports 2011-02-17 04:35:41 +00:00
Campbell Barton
430bb75749 enum-flag arguments were incorrectly documented. 2011-02-16 10:19:14 +00:00
Campbell Barton
4c35d8d5a8 rename IDPropertyGroup to PropertyGroup
also renamed IDProperty to PropertyGroupItem (these are not referenced for common usage and we already have 'Property' defined).
2011-02-16 02:51:56 +00:00
Campbell Barton
a6765280f9 py rna api: turn class.is_register into a class property rather then a class method.
eg:

if MySybclass.is_registered:
    ...
2011-02-14 07:26:07 +00:00
Guillermo S. Romero
7b201c7693 SVN maintenance. 2011-02-14 04:47:55 +00:00
Campbell Barton
e70ca00f71 - move keyingsets_utils.py into modules.
- add gplv2 header
- define __all__ so when importing '*' it wont being in locally defined vars.
2011-02-12 08:12:00 +00:00
Campbell Barton
17efeb310d bpy.utils.register_module() generator could go into eternal loop. 2011-02-11 01:27:00 +00:00
Campbell Barton
2f4f046b6f UI functions added to existing UI classes (operators adding their own menus for eg),
would stop the entire menu from drawing if they raised an exception.

now print the exception and continue.

Also added a verbose argument for bpy.utils.(un)register_module() to help test whats being registered.
2011-02-11 01:12:01 +00:00
Campbell Barton
b1cdf5c344 use weak references for the internal metaclass typemap,
this should help with blender leaking memory with python classes though the bug is still not fixed.
2011-02-11 00:39:07 +00:00
Campbell Barton
fb8c135584 minor python register changes.
- KeyingSetInfo classes are now collected like Panels, Operators etc so bpy.utils.register_module() can be used.
- move bpy.types.register() to bpy.utils.register_class
2011-02-11 00:11:17 +00:00
Campbell Barton
4612034cf4 patch [#25809] Auto-Registration as utility function.
This removes auto-registration, committed by Martin r30961.
Realize this is a contentious topic but Brecht and myself both would rather opt-in registration.

TODO:
- addons need updating.
- class list will be modified to use weakrefs (should have been done for existing system too).
- will move bpy.types.(un)register functions into bpy.utils.(un)register_class, currently including these functions in a type list is internally ugly, scripts which loop over types also need to check for these.
2011-02-10 23:48:22 +00:00
Campbell Barton
6c21f4713b mailed Stani Michiels and he's ok to switch his console autocomplete to GPLv2 or later. 2011-02-08 00:01:15 +00:00