Commit Graph

2055 Commits

Author SHA1 Message Date
46417e1362 WIP, low level python UI functions, so far tested popup menu to work with bpyui.pupMenuBegin, menuItemO and pupMenuEnd functions.
And a popup block with python callback with bpyui.pupBlock, beginBlock, popupBoundsBlock and endBlock funcions.

These functions should not be accessed by scripters directly.
2009-02-16 16:17:20 +00:00
95207cec00 2.5
Added RNA wrapping for F-Curve colour settings
2009-02-15 23:28:30 +00:00
b96180ec17 * Added description string to operator types, should be set along with ot->idname when defining ops.
* User interface uses this as a tooltip when NULL or "" is given.
* Python doc generation includes this description 
* Python defined ops take the description as an argument.

* NULL check to image_ops.c, was crashing on exit when there was an image open.
2009-02-12 03:39:56 +00:00
284db61572 RNA: C API
* RNA_blender.h is now generated along with the other files. It is not
  used anywhere yet, and still located quite hidden next to the other
  rna_*_gen.c files. Read only access for now.
* Inherited properties are not copied from the base anymore but
  iterated over. Patch by Vekoon, thanks!
* Array get/set callbacks now do the whole array instead of getting an
  index. This is needed for some layers for example so python can set
  the array as a whole, otherwise the check that one layer has to be
  enabled at all times gets in the way. Also nicer for the C API.
* Also some changes to returning pointers to make the API cleaner, got
  rid of the type() callback and instead let get() return PointerRNA
  with the type included.

The C API looks like this currently:
http://users.pandora.be/blendix/RNA_blender.h
2009-02-02 19:57:57 +00:00
b1a001942a include Py_CmpToRich for python versions lower then 3 2009-01-29 10:22:03 +00:00
ca36e04362 python3 couldn't generate epydocs because python3 needs richcompare functions for C defined PyTypes (it seems). 2009-01-29 09:38:52 +00:00
c86579b11e 2.5: multiple small fixes
- wm draw method is now initialized correct when reading older
  files, but the SDNA bug causing the problem is still unsolved.
  is due to // char pad[8]; not being recognized as commented.
- triple buffer proxy texture test follows spec better now,
  was disabling triple buffer unnecessarily on some drivers.
- some cmake compile fixes related to sequencer pthread usage
  and removed bad level calls lib for player.
- show outliner header buttons in oops mode as well until that
  can be switched in the UI.
- fix region data free issue for tooltips
- warning fixes
2009-01-23 20:36:47 +00:00
88e244ebb9 basic transform for sequencer strips
can transform the strips or move their handles
Still todo, click-drag transform, metastrips support, snapping, markers overlap checks and constrain to valid channels.
2009-01-21 07:01:20 +00:00
97692a3bf5 Changes to functions from blender/windowmanager/intern/wm_event_system.c
Python operator api was using WM_operator_name_call() which was confusing things too much.
Added WM_operator_call_py() which ended up being a very small function and split out operator creation into wm_operator_create()

Python operator now runs the poll() function and raises an error if it fails.

Eventually there should be error messages for poll that python can use to give the exact reason for failing (eg - library linked data, no active object...)
2009-01-18 10:46:26 +00:00
7cd4e2781a RNA
* Finished DNA_lamp_types.h, DNA_world_types.h and DNA_sound_types.h.
* Renamed "parent" struct property to "nested", and also remaining "from"
  usage to "base".
* Added a NEVER_NULL subtype for pointers and use it for all properties
  that apply.
* Make sure all structs have a description, and fix any other DOC_BROKEN
  descriptions, also many other naming consistency improvements.
2009-01-10 22:57:33 +00:00
1beef956ca 2.5
Instead of many commits, here 1!

- Constraint edit code back
- Removed XXX stubs for constraints
  (make parent follow path works)
- Removed XXX stubs for armature
  (make parent deform, do center, etc works)
- Found a bad uninitialized global Scene * in code, especially
  in kernel it wreaked havoc.
- added missing include in blenkernel/brush.c
- fixed Nicholas' fix for editmode subsurf crash
  (It needed to check for editmode)
2009-01-10 19:34:23 +00:00
e60be63d23 added rna property "parent" so nested RNA structs can access their parent RNA struct
This is used for generating docs so a nested RNA struct such as MaterialRaytraceTransparency are listed under Material rather then in the global struct list)
These RNA structs are used for grouping properties and don't correspond to a C structure.
2009-01-09 16:08:47 +00:00
8140c76ac6 RNA: fix crash in python code, forgot to update this part in a previous commit. 2009-01-08 15:29:09 +00:00
3aae2de773 2.5
Cleanup:
- Makefile was using confused link order, now all intern and
  and extern libs are put after blender and editor libs
- Old stubs.c in editors/screen removed. The leftover python 
  stubs calls were moved to python module.
2009-01-05 17:20:40 +00:00
Nathan Letwory
9e7643aa7c 2.5 / Cleanup
- remove Verse support. This will be brought back in The Future (probably jiri + me)
  This means 5k lines less in blenkernel.
- fix two small errors for global cleanup, now compiles properly with FFMPEG enabled too.
2009-01-04 18:16:34 +00:00
5d23eaa8f4 python support for reporting with operators.
* errors in python called operators are raised as errors
* Python defined operators errors are reported as errors (not full traceback yet)
* added BKE_reports_string, same as BKE_reports_print but it returns a string rather then printing it.
* WM_operator_name_call optionally takes an initialized report struct
2009-01-02 07:54:38 +00:00
112385660a RNA
* Object has some more properties wrapped, mostly game related.
* Scene frame changes now send a notifier.
* Added functions to create/free operator properties for calling
  operators. This also simplifies some duplicated code that did
  this. Ideally though this kind of thing should use the properties
  pointer provided by buttons and keymap items. Example code:

PointerRNA ptr;

WM_operator_properties_create(&ptr, "SOME_OT_name");
RNA_int_set(&ptr, "value", 42);
WM_operator_name_call(C, "SOME_OT_name", WM_OP_EXEC_DEFAULT, &ptr);
WM_operator_properties_free(&ptr);
2009-01-01 20:44:40 +00:00
c556bbd67d Added some more directory includes for CMake. 2008-12-31 04:37:01 +00:00
Nathan Letwory
11e50fb581 2.5
* make bpy compile with msvc again. The forward declaration of the array with no length was a problem. Instead, I switched the tables and made the function a forward declaration.
2008-12-30 00:35:31 +00:00
3e29ff7204 * was using __members__ to get a list of attributes, has been deprecated in python for a while now. use a "__dir__" method instead. now dir() works for rna and operator types.
* added array support for bpyoperator doc generation
2008-12-29 12:04:25 +00:00
65fbab9f4d added RNA access to operators pointers to be documented with epy_doc_gen.py.
eg: print (bpyoperator.VIEW3D_OT_viewnumpad.rna.__members__)

docs for bpyoperator
http://www.graphicall.org/ftp/ideasman42/html/bpyoperator-module.html
2008-12-29 03:24:13 +00:00
f9fd3d7139 minor changes and error checking.
tested first PyOperator, basics work now, invoke/exec can be used to make an operator that edits RNA or calls other operators.
2008-12-28 13:03:37 +00:00
d8fa5f3db7 include order is important here :/ 2008-12-28 08:49:41 +00:00
f7f9d6a68d missing bpy_compat.h for <3.0 py 2008-12-28 08:46:38 +00:00
625f477554 PyOperator invoke function now receives the wmEvent and default properties as 2 python dictionary args.
the Python invoke function can then edit the properties based on the event, once its finished the properties are copied back to the operator.

python exec and invoke functions can now return RUNNING_MODAL, CANCELLED, FINISHED, PASS_THROUGH flags

Still need to look into how python operators can make use of invoke/exec for a practical case. (Need to bring back the popup menu's)
2008-12-28 08:41:49 +00:00
b7c7057f3e * converting operator props to strings was using a float as in int.
* PyOperators were always calling the python functions with default args.
* Made operator prints only happen when G.f & G_DEBUG is enabled.
2008-12-27 16:35:15 +00:00
0714d28236 python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.

Python functions for invoke and exec can be registered with an operator name.

keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.

def exec(size=2.0, text="blah"): ...

is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);

prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");


TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
a2369a5e01 run python when starting blender like 2.4x does (was start/stopping python for each script before)
This way python can call the operator to run other scripts
eg...
 bpyoperator.SCRIPT_OT_run_pyfile(filename = "myop.py")
2008-12-27 04:55:45 +00:00
2431c6667c * Added bSound to rna (still need to do bSample and bSoundListener structs)
* rna epy doc-gen was failing when trying to sort None
2008-12-26 16:50:05 +00:00
7715e45a7a removed ED_ prefix from script operator.
python operator api was crashing when unknown operators were called.
2008-12-26 12:39:53 +00:00
d6704568f8 2.5
Operator calls: extended WM_operator_name_call() with options whether to
call the exec() (operate immediate) or invoke() (check user input) entry.

This will allow python to use it more efficiently, but also solves the
dreaded pulldown case that showed another menu for confirmation.

New names to learn: :)
WM_OP_EXEC_DEFAULT
WM_OP_INVOKE_DEFAULT

on todo still: allow hotkey definitions to do same.
2008-12-26 12:21:06 +00:00
de9437e57a * temporary PKey in the script and 3D view runs "./test.py" (for testing PyOperators that need to run in the user interface context atm)
* added ED_SCRIPT_OT_run_pyfile that takes a filename argument.
* RNA_property_string_set didn't add a value to ID props if the prop wasnt there (like ints, floats and bools do)
* bpy_operator.c - raise an error when unknown keyword args are passed to any operator .

Examples of bpy operator api...

bpyoperator.ED_VIEW3D_OT_viewhome(center=1)
bpyoperator.ED_SCR_OT_frame_offset(delta=10)
bpyoperator.ED_VIEW3D_OT_make_parent(type='OBJECT')

At the moment there is no way to stop the operators .invoke() function from running so ED_VIEW3D_OT_make_parent still opens the menu even though it doesn't need to.
2008-12-25 14:17:54 +00:00
46d505194b * PyOperators now parse args using the PyRNA api (wraps ID props internally),
this means it can reuse the function for converting python to RNA types - giving more useful errors.
* Incorrect enum args lists valid values in their exception message (used for PyRNA and PyOperators).
* remove bpy_idprop.c and bpy_idprop.h

PyOperators are not usable since they run outside the UI loop atm.
2008-12-25 10:48:36 +00:00
3c612bc0e2 2.5
Fix: popup menus were not freeing operators.
Made a new Popup menu call for this case:

uiPupmenuOperator(C, maxrow, op, propname, menustr);

It will set enum "propname" to the menu item and call operator,
register it optionally and free it. Use it in "invoke" calls.

Next: automatic menu generating for enum properties!
2008-12-24 14:52:17 +00:00
Nathan Letwory
521fe6739a 2.5 / SCons
New priorities for most libs, at least core. This is still for Blender proper, BGE and such still to come.
2008-12-23 21:20:34 +00:00
b163840dfb Adding back python 3.0 calls, they didn't build with py2.x because I missed including bpy_compat.h, tested building with 2.6 2008-12-21 12:40:02 +00:00
f44d8c2780 2.5
New Python code: Fixes for Makefile and compat hacks for py 2.3 
Campbell should check though!
2008-12-21 10:56:14 +00:00
170b748c81 2.5 - Compiling 'hacks' for py
* Unicode calls in bpy_idprop.c were causing linking errors here. Probably Py-libs for windows would need recompiling with unicode before we can enable this. For now, commented out the offending calls.
2008-12-21 10:36:29 +00:00
4a86a07f8a wip operator py-api
"operator.ED_VIEW3D_OT_viewhome(center=1)" calls the operator, converting keyword args to properties.
Need a way to run scripts in the UI for useful testing.

Still need to deal with operator exceptions and verifying args against operator options. 

Added temporary WM_operatortype_first() to allow python to return a list if available operators, can replace this with something better later (operator iterator?)
2008-12-21 08:53:36 +00:00
4ea449129e string args were given in wrong order. 2008-12-19 05:09:17 +00:00
b6121d2423 epy doc generator that runs inside blender2.5, in background mode.
Automatic support for...
* cross references to struct types
* extracts descriptions/names
* RNA "base" types are converted to python subclasses
* number min/max, string max length, array's, array lengths, valid enum types, readonly flag.

interesting pages (abusing autobuilder ftp :/)
http://www.graphicall.org/builds/builds/autobuilds/rna/class-tree.html
http://www.graphicall.org/builds/builds/autobuilds/rna/rna.Sequence-class.html
http://www.graphicall.org/builds/builds/autobuilds/rna/identifier-index.html

docs are generated in source/blender/python/doc
2008-12-19 05:05:23 +00:00
6c2750a6fe Added "bpydoc" to the global namespace of python scripts, making documentation available no matter what data is open in the current blend file, Directory type was also missing from the subtype enum causing the test rna-dump script to fail. 2008-12-16 16:32:48 +00:00
e8effb2d0f started whiping cmake into shape for 2.5 still need to figure out
the rna stuff but its close.  Need to get it working for
blender then copy over same to game engine.

Kent
2008-12-12 20:41:30 +00:00
6a6b386832 Made PyRNA props iterable, so you can do things like...
for ob in bpy.objects:
	print(ob.name)

for i, lay in bpy.scenes["Scene"].layer:
	print('%d %d' % i, lay)
2008-12-02 15:27:10 +00:00
9f27be3b2d Added RNA functions from PyRNA
* RNA_property_enum_value
* RNA_property_enum_identifier
To get an enum string from a value and a value from an enum.

BPy_StructRNA types (objects, meshes, images etc) can now be used as dictionary keys.
2008-12-02 14:36:35 +00:00
f8d5883a5b mingw was giving errors...
source\blender\python\intern\bpy_rna.c:1018: error: initializer element is not constant
source\blender\python\intern\bpy_rna.c:1018: error: (near initialization for `pyrna_prop_Type.tp_get

Assign get generic get/sets before PyType_Ready runs
2008-12-02 09:35:29 +00:00
Nathan Letwory
accfa06ede * after discussion with cambo on IRC, change the #ifndef's to #undefs instead:
Pre-Python 3.0 has strings default non-unicode, so checks and handling should be done so too.
2008-12-01 23:38:22 +00:00
Nathan Letwory
d1e75c215b * make sure there are no redefinitions (I'm using py2.5 and ie PyUnicode_Check define exists 2008-12-01 22:20:18 +00:00
6a73a27d81 PyRNA structs and properties can now be subtyped to add functionality in python.
rna_actuator.c was missing an enum
2008-12-01 16:59:18 +00:00
3a22ddeb04 PyRNA epydoc style docstrings.
examples...

RNA Lamp: Lamp
==============
@ivar rna_type: RNA type definition. *readonly*
@type rna_type: PyRNA PointerProperty
@ivar name: Unique datablock ID name. (22 maximum length)
@type name: string
@ivar adapt_thresh: Threshold for Adaptive Sampling. in (0.000, 1.000)
@type adapt_thresh: float
@ivar area_shape: Shape of the Area lamp
@type area_shape: enum in [SQUARE, RECTANGLE]
@ivar area_size: Size of the area of the Area Lamp. in (0.000, 100.000)
@type area_size: float
@ivar area_sizey: Size of the area of the Area Lamp. in (0.000, 100.000)
@type area_sizey: float
- snip

RNA Object: Object
==================
@ivar rna_type: RNA type definition. *readonly*
@type rna_type: PyRNA PointerProperty
@ivar name: Unique datablock ID name. (22 maximum length)
@type name: string
@ivar data: Object data. *readonly*
@type data: PyRNA PointerProperty
@ivar fake_user: Saves this datablock even if it has no users
@type fake_user: bool
@ivar library: Library file the datablock is linked from. *readonly*
@type library: PyRNA PointerProperty
@ivar loc:  in (-inf, inf)
@type loc: float[3]
2008-11-30 14:00:14 +00:00