Commit Graph

220 Commits

Author SHA1 Message Date
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
d741b37236 flag to make rna props 'thick wrapped', so returning a property wont try maintain a reference to the original rna property with callbacks.
also needed for functions that return vectors/matrix's
2009-12-28 22:59:09 +00:00
d64834a6ce Python attribute lookup. Don't use RNA functions that don't have defined callbacks (can happen for operator functions used for registration only). 2009-12-28 22:48:10 +00:00
bbe13e7823 * register operators like other classes
* operators now return sets (converted into flags)
* can't remove bpy_operator_wrap.c since macro's still use the custom register funcs
2009-12-24 19:50:43 +00:00
4dd3e6c360 support for registering operators using the same internal rna api as panels, menus, headers & render engines since there was a fair bit of duplicate functionality.
will remove the old system and update scripts next.
2009-12-24 16:10:26 +00:00
bb452f29d6 minor pyapi changes 2009-12-24 11:40:14 +00:00
b3f03250de use tp_getset rather then checking the string on getattr for 'id_data' attribute 2009-12-13 10:46:34 +00:00
cff8de339d [#20288] FBX exporter fails
* disallow registering operators that have properties starting with an underscore which caused this problem.
2009-12-11 00:51:14 +00:00
901962c621 return value was included in the list of optional args for function-rna error message 2009-12-10 11:20:43 +00:00
b5740b0e77 remove ICON prefix from the enum, for python this is redundant eg.
layout.prop("setting", icon='ICON_BLAH_BLAH')

Also reverted previous commit, the cursor subtype just needed to be added to the switch statement.
2009-12-10 10:23:53 +00:00
7fcb5d33ff values that had units set would not be coerced into Mathutils types by the python api.
eg. scene.cursor_location wasnt a vector
2009-12-10 09:38:58 +00:00
fccceaa87f - pyrna support for (value in array), currently only 1 dimensional arrays.
- use python malloc's in bpy_array.c
- automatically blending bone locations is disabled if the target bone has locked location
- neck had incorrect roll
2009-12-08 09:40:30 +00:00
764c4c94fa use sets rather then tuples for enum/flags so you can use bitfield operators 2009-12-07 02:20:55 +00:00
750764f411 rna flag PROP_ENUM_FLAG which makes rna props a tuple of enums when converted into a PyObject
only used by wm.invoke_props_popup() currently
2009-12-07 00:16:57 +00:00
062cf438ce remove nasty hack which made StructRNA class instaces have no __dict__,
use __slots__, it seems all the parent classes need to have slots as well for this to work.
all python defined srna classes are checked for this too
2009-12-05 23:41:45 +00:00
3b0e182f71 - property decorators for setting attributes didnt work, hack to prevent every instance of an BPyStructRNA to have its own dictionary, set the tp_dictoffset to 0. attempted to use __slots__ but this doesnt work for some reason.
- made bone.length writable
2009-12-03 21:53:01 +00:00
c410a0e855 rna py api,
generic rna function driver_add(), now returns the driver added (or a list of drivers if all channels are set)
2009-11-25 10:13:24 +00:00
802779eb2d Assorted fixes - compile + drivers:
* Fixed a few compile warnings for scons+mingw
* Driver variables are now added with the ID-type set to ID_OB (objects) by default since this is more convenient
2009-11-25 09:25:58 +00:00
6c55047b40 disallow dynamic sized rna arrays to be returned as mathutils types since it gives unpradictable results if in one case it returns a vector and another a rna float array. 2009-11-24 20:15:24 +00:00
e968017951 - new pyrna api functions srna & prop path_to_id(), useful when setting driver target paths.
This means you can have a pose bone for eg and get the path...
   pose.bones["Bone"]
 uses rna internal functions, so will work for sequence strips etc.

- StructRNA.get(), used for getting ID props without exceptions...
 val = C.object["someKey"]
 or..
 val = C.object.get("someKey", "defaultValue") # wont raise an error

- change rna property for testing if rna props are editable, test the flag rather then calling the function since the function depends on blenders state.

- fix a python exception with the ID-Property popup UI (when editing in more then 1 step)
2009-11-23 23:17:23 +00:00
4cac7c88aa bugfix: uninitialized values 2009-11-23 16:58:24 +00:00
dc5b0c8b9c rna functions were getting away with passing the string "True" instead of True, changed get the integer value and test its 1 or 0.
allow rna function return values as an exception since so many poll functions do... "return (context.blah and context.foo)", that makign all return bool's isnt that nice.
2009-11-22 21:51:12 +00:00
adb14a2247 remove template uiTemplate_view3d_select_faceselmenu 2009-11-22 10:02:32 +00:00
acf0fbbf70 left in print 2009-11-20 21:00:09 +00:00
34e7eb1676 use a metaclass to have operator attributes register and display in the order defined. 2009-11-20 20:58:46 +00:00
3119eaf284 - dir() now works for collection functions
- group.objects.link/unlink use exceptions rather then return values
- scene.add_object/remove_object --> scene.objects.link/unlink
2009-11-20 10:00:54 +00:00