Commit Graph

23 Commits

Author SHA1 Message Date
a7c4009267 Make RNA an Operator dir() work in py 2.5 - 3.0
removed epy docstrings from RNA python api, since Python can get this info from rna. (could be redone in python if getting doc's on RNA is needed)
epy_doc_gen works again
2009-03-05 12:09:30 +00:00
Nathan Letwory
0229621b51 2.5 / PyRNA
* a collection of small changes after review together with Campbell.
2009-03-05 08:53:29 +00:00
b49b02842a update to build with python 3.0.1 which removed Py_InitModule3, added richcompare functions to the operator api. 2009-02-26 05:50:19 +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
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
8140c76ac6 RNA: fix crash in python code, forgot to update this part in a previous commit. 2009-01-08 15:29:09 +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
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
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
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
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
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
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
18f3e5d69f PyRNA
Can now assign RNA arrays from python lists of bools/ints/floats
 eg -> rna.scenes["Scene"].layer = [True] * 20

Also added exceptions when trying to set readonly properties.
2008-11-30 03:52:07 +00:00
bc99bbde21 mistake in comparing pointers. (causing memfree prints) 2008-11-30 02:30:34 +00:00
2ff4ac139b PyRNA - can write variables now (float, int, bool, enums, strings - but not pointers, RNA limitation too).
also fixed reading enums.
2008-11-29 17:58:17 +00:00
f23894c365 Python RNA API
* Matches the C/RNA api structure
* Thin wrapper ~(600 lines)
* No functions specific to any blender object type.
* Defines 2 types, BPy_StructRNA and BPy_PropertyRNA.
* Python 3.0 target (compatible with python 2.4,5,6) 
* http://wiki.blender.org/index.php/BlenderDev/Blender2.5/PyRNA - continue docs/discussion here.

Todo
* Collection iterators
* Write access to data
* Define how constants should be accessed (as strings or some special type)
* Solve the "Python keeping invalid blender pointers" problem.
  This cant just be solved in the py api - we need blender to notify when ID's are removed 

Examples
Here are some examples that work with the current implementation of the api.

 rna.lamps["Lamp.006"].energy -> (1.0)
 rna.lamps["Lamp.007"].shadow -> ("NOSHADOW")
 rna.materials.keys() -> ['flyingsquirrel_eye', 'frankie_skin', 'frankie_theeth']
 rna.scenes["hud"].objects["num_text_p2_4"].data.novnormalflip -> False
 rna.meshes["mymesh"].uv_layers.keys() -> ['UVTex', 'UVTex']
 rna.meshes.items()

For a dump of yo-frankie level see - http://pasteall.org/3294/python

Notes
* Added python back, can only execute scripts from the command line with -P script.py
* bpy_interface.c is just enough functionality to run a python file.
2008-11-29 13:36:08 +00:00