Commit Graph

131 Commits

Author SHA1 Message Date
Campbell Barton
52f92b4cb1 lazy load modules for more scripts. 2011-02-27 14:16:32 +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
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
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
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
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
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
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
Campbell Barton
1a41d2fc29 new bpy function bpy.path.module_names(path, recursive=False)
addon's and python initialization both had this inline.
2010-09-08 04:55:37 +00:00
Campbell Barton
115b256738 ran through pep8 checker 2010-09-07 15:17:42 +00:00
Campbell Barton
7a31417f50 apply UserPrefs and Theme rna naming changes. 2010-08-17 13:14:41 +00:00
Campbell Barton
ab8ccaa709 python declarative UI
- remove XML testing feature
- add 2 modules: bpyml - generic, bpyml_ui - blender spesific. nothing uses these now.

==bpyml_ui module==
defines BPyML_BaseUI and its draw() function which uses the bpyml member of the class instance self.draw_data & self.draw_header_data.

This way declarative ui is opt-in and easy to use by using BPyML_BaseUI as a mix-in class.

==bpyml module==

This module translates a python like XML representation into XML
or simple python blender/ui function calls.

    sometag(arg=10) [
        another(),
        another(key="value")
    ]

# converts into ...

    <sometag arg="10">
        <another/>
        <another key="value" />
    </sometag>
2010-08-11 15:11:30 +00:00
Campbell Barton
057aac553b Experemental XML UI, define panels/menus/headers which load at startup like python scripts.
- 2 panels implimented in properties_render_test.xml (Render Dimensions and Stamp)
- only enabled in debug mode.
- poll() functions are not supported yet.
- as stated above experemental, we'll see if this is at all useful, remove if not.
- XML could be replaced with JSON or YAML.
2010-08-07 16:21:15 +00:00
Campbell Barton
30d180ff0d bugfix [#23194] export UVs miss the extension file
also made all other exporters do this.

Made some internal changes.
- moved path functions from bpy.utils to bpy.path (similar to os.path)
- added functions...
  bpy.path.ensure_ext(path, ".ext", case_sensitive=False) # simple function to ensure the extension is set.
  bpy.path.resolve_ncase(path) # useful for importing scenes made on windows where the path case doesnt match the files.
2010-08-06 01:40:54 +00:00
Campbell Barton
233df907d0 py/rna update, reload works again.
- fix for reload (f8) crashing, missing incref when creating the script namespace.
- store the module names rather then the modules for reloading incase the modules get out of date.
2010-08-03 03:53:36 +00:00
Campbell Barton
0c62d107e0 minor changes to registration before committing addons fixes 2010-08-02 06:56:31 +00:00
Campbell Barton
55e64f0ba4 minor changes to Martni's commit 30961
- removed the immediate option from C/api and now store in python only, when python loads modules it sets it to False.
- unloading a module would clear the entire TypeMap for all modules, only remove the module types that is being unloaded.
- added some checks for bad class registering, report errors rather then crashing.
2010-08-02 04:20:41 +00:00
Martin Poirier
5b345524ea RNA Types metaclass registration
See mailing list posts for details [1][2][3]

Addons still need to be fixed; Campbell said he'd do it today.

See any of the py files (outside netrender) in this commit for how to do it (it's rather simple).

[1] http://lists.blender.org/pipermail/bf-committers/2010-February/026328.html
[2] http://lists.blender.org/pipermail/bf-committers/2010-August/028311.html
[3] http://lists.blender.org/pipermail/bf-committers/2010-August/028321.html
2010-08-02 02:55:12 +00:00
Campbell Barton
fa9550bba0 fix for un-initialized memory use with thumb's & minor internal improvement for bpy.utils.clean_name() 2010-07-28 07:37:24 +00:00
Campbell Barton
15e94823dd in debug mode report the time to load addon modules. 2010-07-26 09:09:53 +00:00
Campbell Barton
fd31436897 spelling correction: alredy --> already 2010-07-17 18:08:14 +00:00
Andrea Weikert
05fb497f75 == installation paths ==
remove deprecated python BLI_gethome_folder calls

Patch by Brecht, thanks a lot
2010-07-15 20:02:53 +00:00
Campbell Barton
1028284301 pep8, whitespace edits 2010-06-09 19:12:03 +00:00
Campbell Barton
9cbbc9d3af rename some rna properties filename --> filepath
* filename == "foo.ext"
 * filepath == "/path/to/and/including/foo.ext"

this was alredy followed in some places not not everywhere.
2010-06-02 17:58:28 +00:00
Campbell Barton
ed3a7bd299 script reload (f8), is closer to working.
there are internal memory problems which can make it crash still.
If you remove all directories in the scripts folder except for 'modules' and 'ui', it runs without crashes.
2010-06-01 08:15:43 +00:00
Campbell Barton
80de1162ee clear some pep8 warnings 2010-05-16 12:15:04 +00:00
Campbell Barton
e8408697de bpy.utils.blend_paths(absolute=False) (was Blender.GetPaths in 2.4x) 2010-05-11 07:08:32 +00:00
Campbell Barton
daba1d23ff utility functions
bpy.utils.smpte_from_seconds(time)
 bpy.utils.smpte_from_frame(frame)
2010-05-10 20:41:01 +00:00
Campbell Barton
6a5c036304 py api. bpy.utils.relpath() function. 2010-04-21 09:27:36 +00:00
Campbell Barton
7eb4eebe22 add the modules directory from the user scripts path (if it exists) 2010-04-16 09:31:58 +00:00
Joshua Leung
ea4a987fd4 == Massive Keying Sets Recode ==
After a few days of wrong turns and learning the finer points of RNA-type-subclassing the hard way, this commit finally presents a refactored version of the Keying Sets system (now version 2) based on some requirements from Cessen.

For a more thorough discussion of this commit, see 
http://sites.google.com/site/aligorith/keyingsets_2.pdf?attredirects=0&d=1

------

The main highlight of this refactor is that relative Keying Sets have now been recoded so that Python callbacks are run to generate the Keying Set's list of paths everytime the Keying Set is used (to insert or delete keyframes), allowing complex heuristics to be used to determine whether a property gets keyframed based on the current context. These checks may include checking on selection status of related entities, or transform locks.

Built-In KeyingSets have also been recoded, and moved from C and out into Python. These are now coded as Relative Keying Sets, and can to some extent serve as basis for adding new relative Keying Sets. However, these have mostly been coded in a slightly 'modular' way which may be confusing for those not so familiar with Python in general. A usable template will be added soon for more general usage.

Keyframing settings (i.e. 'visual', 'needed') can now be specified on a per-path basis now, which is especially useful for Absolute Keying Sets, where control over this is often beneficial.

Most of the places where Auto-Keyframing is performed have been tidied up for consistency. I'm sure quite a few issues still exist there, but these I'll clean up over the next few days.
2010-03-16 06:18:49 +00:00
Campbell Barton
10dbf6faee rename extension to addon after discussion with meta-androcto & mindrones 2010-02-26 14:28:29 +00:00
Campbell Barton
97bdfe6f1b pep8 cleanup + correction for external player operator return value. 2010-02-22 23:32:58 +00:00
Martin Poirier
b602c6b5fa Better code to prevent loading scripts from .blender/scripts
Treat user defined script dir (where loading from base dir is ok) differently than system dirs, where we only want to load from specific subdirs.
2010-02-20 22:57:49 +00:00
Campbell Barton
1a07aa169e temp workaround for blender loading 2.4x scripts in ~/.blender/scripts 2010-02-20 22:12:27 +00:00
Campbell Barton
c72ab0a39e topology based mirror, (from apricot branch)
- correct errors with non-mirrored meshes
- mirror weight paint on asymmetrical meshes
2010-02-17 19:50:42 +00:00
Campbell Barton
768f20d537 update for missing docs & dont include operator classes in sphinx docs. 2010-02-16 15:01:34 +00:00
Campbell Barton
a789942219 ignore scripts that are loaded twice rather then raising an error. 2010-02-16 13:13:22 +00:00
Campbell Barton
37858fd435 make it so an error registering/unregestering wont stop loading scripts, just print the error and continue 2010-02-15 12:43:25 +00:00
Campbell Barton
536e448e7a [#21141] boring segfault on F8/"reload scripts", 26878, backtrace
reloading bpy_types was causing reload to fail. also unregister all modules in the reverse order that they were loaded, so when reloading removed files done hang around.
2010-02-15 10:54:51 +00:00
Campbell Barton
677386e53a initial support for extensions in the user preferences
only one script at the moment:
 [#20848] Blender Gears for 2.5 (for ideasman42)
 from Michel Anders (varkenvarken)
2010-02-14 23:33:18 +00:00
Campbell Barton
39c04315e2 change python scripts so modules which register with blender have a register() function rather then making import automatically run the register functions (generally considered bad practice by python people) 2010-02-14 11:21:21 +00:00
Martin Poirier
5c9f10f673 Remove debug print 2010-02-12 22:02:10 +00:00
Campbell Barton
081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
Campbell Barton
8f4c340915 bpy.utils.home_paths, use this to get script paths for the user/local/system blender paths. 2010-02-11 14:08:22 +00:00
Martin Poirier
7379e75e12 Fix loading python modules (like netrender) 2010-02-01 01:33:40 +00:00
Campbell Barton
95069f2909 pep8 changes 2010-01-31 14:46:28 +00:00
Campbell Barton
026b5bacca bugfix [#20638] not loading script in user script directory when startup 2010-01-30 14:48:46 +00:00
Martin Poirier
21b7556bf7 Add cfg folder for keyconfigs (and possibly others later) to be imported after everything else.
Also remove .pyc file when removing keyconfigs.
2010-01-28 21:52:07 +00:00
Campbell Barton
6f3dfe81c0 missed some files last commit. 2010-01-28 19:21:15 +00:00
Campbell Barton
18ea9b6443 move bpy.load_scripts --> bpy.utils.load_scripts
added sequencer strip length display in seconds
2010-01-28 11:48:06 +00:00
Campbell Barton
9d96399eeb - panel python template
- nicer syntax to capitalize words
2010-01-23 18:51:56 +00:00
Campbell Barton
7f1a8a947d initial sphinx doc generation support for python and C modules.
python modules bpy.app, bpy.utils are now included in docs.
C defined python module bpy.props has its docstrings extracted and written directly into sphinx docs since the C methods cant be inspected.

added docstrings to bpy.props and improved some in bpy.utils.

will update online docs tomorrow.
2010-01-22 02:04:25 +00:00
Campbell Barton
a1656300ba script for automating pep8 checks.
On ubuntu/debian install these tools...

   sudo apt-get install pylint pyflakes python-setuptools python-pip
   sudo pip install pep8

then run from blenders source dir...
   python release/test/pep8.py

This searches for the comments "# <pep8 compliant>" and "# <pep8-80 compliant>", running the checking tools on these scripts only.

* some minor pep8 corrections too.
2009-12-13 13:59:16 +00:00
Campbell Barton
fb28896cf7 * added an armature submenu where python defined armatures can go.
* bpy.utils.display_name(), which makes filenames and module names look nicer in menus eg... /home/me/foo_bar.py  --> "Foo Bar"
* missing rna_path --> data_path renaming
2009-12-11 14:16:59 +00:00
Campbell Barton
5ebe54f470 pep8 edits and fix some warnings 2009-12-05 22:03:07 +00:00
Campbell Barton
e2450e4dd9 multiple script paths broke text template menu 2009-12-02 16:11:10 +00:00
Campbell Barton
33c444f965 User Script support added back.
- the scripts path set in the user preferences or ~/.blender/scripts/ui (io, op, io etc..) will be used to load scripts.
- the default home dir part probably only works in *nix os's

- Added a missing sync callback to vector.toTuple()
2009-11-30 22:32:04 +00:00
Campbell Barton
2e61294cbc simple fixes
[#20123] "Import" menu entry becomes empty
[#20141] In Object menu Make Links appears twice - SVN 24970

also moved OBJs name cleaning func to bpy.utils.clean_name(name, replace="_")
2009-11-28 20:50:31 +00:00
Campbell Barton
771406df94 - hide members of bpy from dir() and autocomp.
- path functions bpy.utils.script_paths(), bpy.utils_preset_paths(subdir)
- further simplified presets, use a generic draw function for preset menus and define the preset subdir and operator in the class
2009-11-22 11:23:19 +00:00
Campbell Barton
4c7dc3e5c5 changes python initialization
- bpy is now a python package, this makes it easier to add utility modules and adjust python startup which was previously using verbose Py/C api. Access should not be any slower since both C and Python modules use dictionary access.
- loop over scripts and load via python (currently F8 reload isnt working, will add back shortly)
- the C module is kept but renamed to _bpy and not meant for direct access from anything but the bpy package.
- bpy_types.py is an exception since it runs before the bpy package is initialized.
2009-11-13 09:28:05 +00:00