Commit Graph

140 Commits

Author SHA1 Message Date
Campbell Barton
6e5ce953da use 'is None' rather then '== None' as suggested by python docs & mis-spelling. 2011-03-29 04:16:55 +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
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
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
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
b25db7c8cb pep8 cleanup 2011-02-25 16:06:14 +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
812f238494 pep8 cleanup and remove unused vars/imports 2011-02-17 04:35:41 +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
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
0362d19f2d Pythons path functions - os.walk(). os.path.exists(). etc support bytes for paths as well as strings, support this with blender/rna too.
- bpy.data.*.load() functions were only accepting UTF-8 paths.
- rna functions/properties now accept byte values rather then strings for file paths.
- bpy.path.resolve_ncase now supports byte objects.
2011-02-01 04:24:47 +00:00
Campbell Barton
743182106f py api: bpy.path.abspath(), option to return relative to a path other then the current blend file. 2011-01-15 20:35:31 +00:00
Campbell Barton
f66912a335 misc edits, no functional changes
- enabling/disabling no longer prints in the terminal unless in debug mode.
- remove 'header' struct from BLI_storage_types.h, from revision 2 and is not used.
- Add GCC property to guardedalloc to warn if the return value from allocation functions isn't used.
2011-01-15 15:48:46 +00:00
Campbell Barton
dacdfbe6f3 recent change to keyframe menu broke BVH import, now don't use the operator at all, instead assign the action manually.
Also added bpy.path.display_name_from_filepath(), since filepaths are not ensured to be utf8.
same as calling:  os.path.splitext(os.path.basename(name))[0].encode("utf8", "replace").decode("utf8")
2011-01-03 08:28:22 +00:00
Campbell Barton
7f3fe8a2df pep8 cleanup 2011-01-01 07:20:34 +00:00
Campbell Barton
54343b79e6 remove reload() from builtins since python3 no longer uses this.
use imp.reload now.

Should use import hooks but for now replace imp.reload with our own reload as the builtin reload was replaced before.
2010-12-22 21:39:48 +00:00
Campbell Barton
c26cc0afa1 bugfix [#25290] Align on text gives a traceback
[#25284] Traceback error on "System Info" script

- Align was only working on mesh objects, now operate on all objects, missing boundbox's are treated as single points.
- obj.bound_box was returning all nan's for object types with no boundbox.
- ENUM_FLAG type enums were showing no text when displayed in operator redo panel.
2010-12-19 07:05:29 +00:00
Campbell Barton
77c17d332d fix [#25262] Keyboard shortcut presets can't be made because of wrong folder
New create option when getting a user resource for creating paths.
  bpy.utils.user_resource(type, path, create=False)
2010-12-18 07:22:52 +00:00
Campbell Barton
3256d0fc6a allow addons/modules path so extension authors can develop their own shared modules. 2010-12-11 11:52:28 +00:00
Campbell Barton
6f90a38a54 error in own recent commit 2010-11-22 23:41:00 +00:00
Campbell Barton
1d468c75e7 bugfix [#24805] bpy operator runs in wrong order or is ignored at all 2010-11-22 17:21:18 +00:00
Campbell Barton
593815b23f reloading addons wasn't working. 2010-11-20 04:18:06 +00:00
Campbell Barton
03d8fd4616 - use relative imports for packages
- reload() has been removed from pythons builtins. use imp.reload() instead (still need to apply globally).
- fixed own mistake, not ignoring 'filter_glob' as a keyword argument (broke fbx, obj, 3ds export)
2010-11-20 02:56:58 +00:00
Campbell Barton
7689ac75ad fix for error in recent commit. 2010-11-19 11:57:10 +00:00
Campbell Barton
23fbce5a5f bugfix [#22615] Opening a blend file in python (bpy.ops.wm.open_mainfile() (r29489)
[#22557] bpy.ops.wm.read_homefile() causes segfault (r29372)
2010-11-18 16:33:13 +00:00
Campbell Barton
64ff9d6de4 fix to allow [#24009] to be fixed.
WM_operator_poll() could fail in cases WM_operator_name_call() would succeed because calling the operator would setup the context before calling poll.
this would result in python raising an invalid error or menu items being greyed out.

now python can also check with an operator context:
  bpy.ops.object.editmode_toggle.poll('INVOKE_SCREEN')
2010-11-04 12:59:03 +00:00
Luca Bonavita
406fd33a86 == addons ==
- new (and temporary) directory addons_extern/ to store external projects addons
2010-10-24 16:01:21 +00:00
Campbell Barton
8bb75bb5b6 bugfix [#24155] Operator Cheat Sheet doesn't work properly 2010-10-06 22:29:34 +00:00
Campbell Barton
ab8aa13b82 bugfix [#24087] Blender can not install add-ons unless running with root priviledges
now addon path is created using the same path functions and selecting where to save the startup.blend

also made some minor changes to path handling funcs.
2010-10-03 20:00:22 +00:00
Campbell Barton
ed7ffb111a bugfix [#24116] UV layout exporting doesnt work
in-fact this is unrelated to UV Layout script, just a missing check for an bad state.
2010-10-03 12:22:33 +00:00
Campbell Barton
3dea67a3fd bugfix [#24065] obj export (mtl image path) 2010-10-01 05:19:40 +00:00
Campbell Barton
92954672dc bugfix [#23978] Error installing addon 2010-09-25 06:36:01 +00:00
Brecht Van Lommel
7428e708ac Fix #23865: F8 reload scripts doesn't work with an addon enabled,
broken with bugfix for #23001.
2010-09-16 18:50:33 +00:00
Campbell Barton
84c4062928 bugfix [#23833] Console Errors (Keymaps)
dont allow non-existing preset paths to be passed to the preset menu.
2010-09-15 13:41:38 +00:00
Campbell Barton
8d0c01e6e2 keyconfig updates/changes
- use preset subclass with funcs for updating the keyconfig
- keyconfig filenames are used for the UI names as with presets (so separation anymore)
- keyconfig's are stored in the preset dir (scripts/cfg dir removed)
- only the active keyconfig script is loaded
- some bugfixes for saving keymaps
- user interactions no longer saves keyconfigs too, I think this needs to be re-worked.

developer note...
multiple keyconfigs at once are not really needed now that they are stored & accessed directly in python.
for now I left it alone but we could consider to remove this capability in the future.
2010-09-14 16:45:24 +00:00
Campbell Barton
74b2022a82 button to remove presets.
note: this is an option to the add preset operator which is a bit odd but easiest since these classes have all the info needed for removal as well.
2010-09-14 04:58:25 +00:00
Campbell Barton
18702a9eef bugfix [#23001] Addons do not unregister properly in Blender 2.5.3
Now reloading the user defaults also unloads/loads addons, resetting the state to the one set in the user preferences.

moved addon functions into bpy.utils
- bpy.utils.addon_enable(name, default_set=True)
- bpy.utils.addon_disable(name, default_set=True)
- bpy.utils.addon_reset_all(name, default_set=True)

the user preference operators now just wrap these.
2010-09-13 04:52:56 +00:00
Campbell Barton
b58f41e120 addon improvements/fixes
- better error reporting when an addon fails to load
- upload an addon which loads partly but then fails (eg, module loads but class register fails)
- bugfix addon loading, failier to load would leave _bpy_types._register_immediate = False
- added which change on disk are reloaded when enabling.
- bpy.path.module_names() now returns (module_name, module_path) pairs.
2010-09-08 07:30:20 +00:00