Commit Graph

345 Commits

Author SHA1 Message Date
15f0907563 PyAPI Bugfix - Fix for crash on struct.path_to_id() 2010-03-14 11:44:24 +00:00
969b4673c7 Python/RNA: added collection.move(from, to) for python defined
collection properties.
2010-03-10 20:54:14 +00:00
a53ef075ae python api function for rna objects: object.as_pointer()
This means we can write low level apis in pyton or C where blender data is passed to external C modules without having to have blender support this directly.

Example use case is to get an image pointer then use ctypes to get the image buffer and pass it to a C image processing function.
2010-03-06 12:37:29 +00:00
c0984d59cc Delete keyframe API method now takes array_index = -1 to delete keyframes from entire arrays, as for insert keyframe.
Enabled the 'keyframe_delete' method for RNA structs.
2010-03-01 10:43:02 +00:00
c76b6fcb06 utility function pyrna_enum_value_from_id for getting the enum from a string and raising an error if its invalid. 2010-02-27 15:28:34 +00:00
ddacff06f2 hold the python operator instance in the operator, otherwise the handelers need to be stored in the operator type or in the module which isnt nice for modal operators. 2010-02-27 14:44:46 +00:00
b6acf0bb48 python support for defining region drawing callbacks, while not directly related to operators, this means python can now make operators that draw in the 3D viewport interactively.
nicer then 2.4x space handelers because you can register draw handelers to draw pre/post 3d space or in pixel space.
2010-02-27 13:27:06 +00:00
bbf6dde277 rna/py api
rename image.save() --> image.save_render() because it uses render settings for saving.
added image.save() which is like pressing save in the image view, saving to the images path and removing the dirty flag.
2010-02-26 12:28:44 +00:00
ca5e7113d3 allow python api to set values of library liked data (still checks editable flag)
+ improved exception messages.
2010-02-23 11:19:55 +00:00
4ef1fd1078 game engine support for recording animation back & some other minor changes. 2010-02-22 12:25:58 +00:00
e31d0198e6 exclude self references from the ID search list when PROP_ID_SELF_CHECK is set, also raise an error from python if this is attempted 2010-02-22 08:27:45 +00:00
6589038350 python rna api now clamps values, (was fun to see the spot_size go backwards)
Vector callbacks still missing clamp checks
2010-02-21 14:48:28 +00:00
02e7871149 Mathutils API: Euler support for rotation order.
Examples.
 euler = Euler(1, 2, 3)
 euler.order = 'ZXY'
 
 euler = matrix.to_euler('XZY')


Still missing rna support. this still wont give the right order, defaulting to XYZ.
 eul = object.rotation_euler
2010-02-20 19:49:04 +00:00
0b3dfc441e pyrna, adding back foreach functions from collections. they are needed! 2010-02-16 19:27:38 +00:00
d8ce09ce53 bugfix [#21173] Autocompleate raises an error
split PropertyRNA off into 3 types, base type, collection and array, since array and collections needed internal checks inside almost every function its better to have the, as subclassed to the property type. This makes introspection more useful.

Also made printing of structs and properties prettier giveing type and length.
2010-02-15 23:43:51 +00:00
882af97b4b classes were having their dictionary cleared when the blender extension data was freed which made re-registering fail.
now extensions can be enabled and disabled without having to reload them.
2010-02-15 11:24:43 +00:00
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
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
533ed7cdaa Python deprcated PyCObject, use PyCapsule instead. 2010-02-12 21:14:01 +00:00
081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
c2b2ccde45 fix for python not being able to call operators with a executuon context. 2010-02-10 11:10:38 +00:00
52b1c37645 [#21039] OBJ import Clamp Scale limited to .01 as lowest Value. Used to be Zero
[#21053] 2.5alpha0 export obj problem
+ some minor changes.
2010-02-09 19:22:57 +00:00
fc123a40d3 patch [#20889] Support "unit"s for FloatProperty
from Martin Bürbaum (pontiac)
(with own minor changes)
2010-02-02 23:03:56 +00:00
039d087171 subtype support for properties in bpy.props. 2010-02-01 22:04:33 +00:00
53f8bbd798 bpy.props.IntVectorProperty & BoolVectorProperty 2010-02-01 10:51:34 +00:00
ec48cbd267 utility functions is_negative_m3 & is_negative_m4, added python Mathutils access Matrix.is_negative
renamed Mathutils attribute wrapped -> is_wrapped
2010-01-30 13:15:39 +00:00
e28e6ac5c7 Fix the underlying problem from the last commit, which was worked
around incorrectly in r24435 before that. freeptr in BPy_StructRNA
was uninitialized when creating bpy.context.
2010-01-29 14:49:21 +00:00
5abb38e566 Bugfix
OSX 10.5 PPC kept crashing on exit. After blaming bad compiles, bad python libs
and all other reasons (almost was switching to linux!) brecht found the bad line 
in python free code. There was code freeing stuff whilst it wasnt allowed to.

Mac PPC gets hug!
2010-01-29 14:13:40 +00:00
89cd4be1af slice assignment wasnt running the properties update function (setting object layers wasnt working from py)
also commented operator subclassing, loosing py property order.
2010-01-27 17:23:28 +00:00
49abcd49f1 fix for crash when using a NULL context from python 2010-01-27 10:54:11 +00:00
586af8ca47 Properties for macro operator call in python.
Dicts are converted to operator properties like this:

bpy.ops.armature.extrude_forked(TRANSFORM_OT_translate={"value":(2,0,1)})

Note that this doesn't work quite well if one operator is twice in the same macro, but that's a problem at the RNA level too. I'll have to deal with that eventually.
2010-01-26 20:43:27 +00:00
d5ca236948 Typo in error string 2010-01-26 17:37:44 +00:00
9733e902a5 RNA functions
Fixed and completed support for returning multiple values. This includes support for returning arrays, both fixed and dynamically sized. The way this is achieved is by storing an additional int value next to the dynamic parameter in the ParameterList stack which gets passed to the C function as an additional parameter. In the case of return parameters it is duty of the C function to set this int to the correct length value for the dynamic parameter (which makes sense). Note that for the dynamic output/return parameter it is assumed the function has allocated that memory (which gets freed automatically).

Also, I cleaned the makesrna's bridge function generation code a bit and renamed PROP_RETURN to PROP_OUTPUT, which represents better the reality now that there are multiple returns. The function now to mark multiple returns (outputs) is RNA_def_function_output.

For an example, look at Action.get_frame_range in rna_action_api.c, by the way Aligorith I removed the #ifdef for this function now that there's support for returning arrays, feel free to modify (the function seems to work).
2010-01-24 10:51:59 +00:00
2f6a158d21 when python calls an operator, return a set from the operator flag, this matches the set that python operators themselves return. eg.
{'MODAL'} or... {'FINISHED'}
2010-01-23 01:02:53 +00:00
ad65d6995c use string/int/length lookup functions for bpy.types, gives 20-30% overall startup time speedup on my system. 2010-01-22 14:06:42 +00:00
9790647ce6 BPY: fixed iteration over and slicing of multidim. arrays. 2010-01-20 14:06:38 +00:00
849024df83 patch [#20724] Randomize Loc Rot Size py operator for B2.5
written from scratch by Daniel Salazar (zanqdo). added own modifications.

New property type
 bpy.props.FloatVectorProperty(), only difference with float is it takes a 'size' argument and optional 'default' sequence of floats.

moved bpy.props.* functions out of bpy_rna.c into their own C file.
2010-01-19 00:59:36 +00:00
c7dfa96aea bugfix [#20639] BF25_SVN_25888 and below - OBJ and 3DS import fails
blender supports type changing for textures in a way that python doesnt.
add a new general function.

Example usage:
 tex = bpy.data.textures.new("Foo")
 tex.type = 'IMAGE'
 tex = tex.recast_type()

Macro to give the number of users accounting for fake user.
 ID_REAL_USERS(id)
Use this so you can remove a datablock if it has a fake users as well as apply transformations to it in the 3D view.

Move api function bpy.data.add_texture() --> bpy.data.textures.new()/remove()
2010-01-17 20:06:34 +00:00
5272991e8b generic operator menu was searching for "type" and using the first enum property if it wasnt found.
this is too arbitrary and could break if roperty order is changed.
store the property in the operator type that is to be used for menu and enum search func's.

python function for searching operator enums on invoke. (just need dynamic python enums now)
 wm.invoke_search_popup(self)
2010-01-15 22:40:33 +00:00
08c9ecb3b0 RNA/Py API
change how data is added. eg.
 bpy.data.add_mesh(name) --> bpy.data.meshes.new(name)
 bpy.data.remove_lamp(lamp) --> bpy.data.lamps.remove(lamp)


image and texture stil use add_* funcs
2010-01-09 23:44:01 +00:00
a868e8623c - RNA support for returning copied strings from functions, flagging strings as PROP_THICK_WRAP does this.
- scene.render_data.frame_path(frame=num), returns the output path for rending images of video.
- scene.render_data.file_extension, readonly attribute, gives the extension ".jpg", ".mov" etc
- player support was guessing names, use the above functions to get the actual names used, accounting for #'s replacing numbers.
2010-01-08 13:52:38 +00:00
3b5014c69b Python descriptions were not getting used in tooltips. 2010-01-05 20:19:54 +00:00
01b762e846 fix for bpyob.foreach_set(), when the list is empty 2010-01-05 13:55:51 +00:00
e90b6eefb1 patch from Benoit Bolsee (ben2610) for 4 bugs in report [#20527] Several bugs in RNA
from the report...


# bug 1. UV properties are not raw editable but are reported 
#        as RAW_TYPE_INT by RNA causing wrong conversion 
#        internally (bpy_rna.c line 2205)
# bug 2. raw update of UV coordinates crash blender (rna_access.c line 252)
mtfaces.foreach_set("uv", rawuvs)
# workaround:
#for i in range(int(len(faces)/4)):
#   mtfaces[i].uv = uvs[i]

# bug 3. raw update of non-array property fails (rna_access.c line 2270)
mfaces.foreach_set("material_index", mats)
# workaround:
# for i in range(int(len(mfaces))):
#    mfaces[i].material_index = mats[i]

# bug 4. It is not possible to add a vertex color layer using mesh API.
me.add_vertex_color()
# no workaround...
2010-01-04 22:30:09 +00:00
bed3c5254f pyrna array slice assignment
- accept any sequence
- disallow deleting & resizing via slices
2010-01-04 20:53:52 +00:00
d1da5cb99a support for rna functions returning mathutils types - so object.rat_cast() returns Mathutils vectors rather then tuples 2010-01-04 13:29:55 +00:00
cf7b19c0ba fix for mistake in last commit. also forgot to call RNA_parameter_list_end() in some places, (ok the function does nothing now, but some day it might do) 2010-01-02 19:01:19 +00:00
78b2eb8d3c PyRna float/bool/int slicing.
- fixed slice assignment.
- fix for slowdown where getting a slice would get the entire array and free it for every item in the array (malloc and free for arrays >32).
- fix for thick wrapped returning an array referencing the original pointer when coercing into a mathutils type failed.

TODO
- slice assignment currently only sypports lists.
- dimensions are ignored for multidimensional arrays.
2010-01-02 17:33:44 +00:00
e83940d994 support for multiple return values from rna functions & support for returning arrays, (no functions are using this yet).
patch from Elia Sarti, (vekoon) with some modifications mainly for the python api.

- multiple values are returned as a typle in the order that are defined.
- added support for registered types returning multiple arguments (untested).
- renamed func->ret --> func->c_ret, since this only defines what the C function returns.
2010-01-02 10:42:38 +00:00
b00cddeb66 Macro registration using the normal rna registration methods (like operators).
bpy.types.register(MacroClass)

instead of

bpy.ops.add_macro(MacroClass)

The rest is unchanged.

Also remove some now unused code for the old registration methods (there's still some remaining).
2009-12-30 22:14:32 +00:00