From BlenderWiki
2.42 Release
Python Expressions
Better Integration
Blender 2.42 gives access to Python evaluation for numerical gui fields (buttons) and ipo drivers. So now users can write expressions in Python to define button values and to control ipo channels, like an object's location, rotation and scale, plus many more possibilities.
It does require some knowledge of Python and basic mathematics for anything but the most trivial uses, but even someone with absolutely no interest in programming can benefit from expressions written by other users, of course.
Button Evaluation
Any button in Blender that accepts a range of integer or float values accepts now a Python expression, as long as it evaluates to a number.
Important: to tell the program that you're entering an expression, it needs to start with the hash symbol (#), that's the only difference between expressions for buttons and for pydrivers, where the hash should not be used.
PyDrivers
- About Ipo Drivers
- "An IpoDriver is like an IpoCurve, but instead of a Bezier curve, it allows to connect a property of other Objects as input for the "channel". For example, IpoDrivers can be used to have a Shape Key being "driven" by the rotation of a Bone. Or the RGB colors of a Material get driven by the XYZ location of an Object."
- Where they are
- "Editing of Drivers happens in the IpoWindow. Here you can notice that the channels (...) now have an "active" channel indicator. To add a Driver, you have to use the "Transform Properties" Panel (Nkey). Here you can add or remove a Driver to the active channel, and use the buttons to fill in what kind of relationship you want to establish."
(excerpts taken from http://www.blender.org/cms/Ipo_Drivers.680.0.html maintained by Ton Roosendaal)
- About Python Ipo Drivers
- Pydrivers allow to use one-line Python expressions as input for a channel, instead of using a property of another object, like normal ipo drivers do. An expression in programming is any combination of symbols that can be evaluated to a definite value.
- Where they are
- When adding a driver, like explained above, click on the small "Python" icon at the "Transform Properties" panel and a text input box will appear. Write your py expression there.
Usage Instructions
The information below is valid both for buttons and pydrivers.
Python evaluation opens up many interesting possibilities: we can use mathematical functions and more general programming to define button values or drive object animations. (Note for Python programmers: this is equivalent to what the builtin eval() function does.) The only restriction is that the pydriver expression itself must return a real number when evaluated and not, e.g., a string or something else.
A simple example for drivers would be using sines or cosines to make objects oscilate around a given point, for example. Or (ugh) using random values at each animation frame to change some material attribute, like diffuse rgb, alpha, etc.
Valid Expressions
We've already told the basics: there are text input boxes where you can type expressions in Python. Here are some examples of valid expressions (reminder: these are for pydrivers, prepend a '#' to use them in number buttons):
- any real value:
1.0 - expressions with numbers and operators:
4.5 + 8.9 * 7.0 - (2 / 3.0) - expressions also with variables:
math.pi * 2 + 5.0 - available data:
Blender.Get("curframe") # the current animation frame - a little math:
math.sin(Blender.Get("curframe")) # the sine of the current frame!?
Builtin resources and aliases
Pydrivers and "pybuttons" use their own global dictionary that is cached and only gets recreated when any expression fails.
In this dictionary we pre-import a few modules so they can be used inside expressions:
Note: to save typing and keep expressions smaller, we've added aliases for each module: Blender can be referenced as "Blender" or simply as "b". Below each module is followed by its available aliases:
- all from builtin (the default builtin module)
- Blender: blender, b
- Blender.Noise: noise, n
- math: math, m
Example expression:
m.cos(m.pi * b.Get("curframe") / n.random())
Aliases were also added for a few commonly needed data:
-
ob(name)is equivalent toBlender.Object.Get(name) -
me(name)is equivalent toBlender.Mesh.Get(name) -
ma(name)is equivalent toBlender.Material.Get(name)
Example expression:
ob("Cube").LocX + ob("Lamp").RotZ
The pydrivers.py Blender text
Besides the above modules, if there's a Blender text called "pydrivers.py" loaded in the Text Editor, it's also imported:
- pydrivers: pydrivers, p
This allows users to create their own functions and add their own variables without the restriction of the one-line py expression. For example, if your pydrivers.py text looks like this:
myvar = 10.0 def myfunction(arg): # do something fancy here return float_val
You can access both myvar and myfunction inside any expression:
Example expression:
p.myvar * p.myfunction(2) - 1
Note: if you make updates to the pydrivers.py text, go to the Ipo window and click in any pydriver's text input box (in the Transform Properties panel), then click out of it or press ENTER, to force reloading the pydrivers.py module and to update all pydrivers at once.
Demo .blend files
Old entry in the patch tracker: Pydrivers
There are a couple of lousy .blend files there, too, demonstrating a few possibilities. Please check the README text in each .blend to get specific info about them.
Links
- Check the docs in this very wiki's Main Page for Blender and Blender Python API references.
- Python and its documentation
- this might be a good hunting ground for those looking for functions to try with pydrivers: http://functions.wolfram.com/ (newcomers are recommended to start with elementary ones, specially trigonometric).
- Finally (and again), the patch tracker entry, with patch and sample .blend files for pydrivers: right here
Pack Access
Applied pack unpack from Pablo Martin (caedes), http://projects.blender.org/tracker/?func=detail&atid=127&aid=3246&group_id=9 adds Blender.c: Blender.UnpackModes (dict with the unpack modes) Blender.UnpackAll(mode) Blender.PackAll() Blender.CountPackedFiles() Image.c: image.packed (this was working) image.pack() image.unpack() Sound.c: sound.packed sound.pack() sound.unpack()
Python Mesh API
A couple of bug fixes and enhancements:
(1) Setting the UV attributes of a mesh face will create texture faces if
they are not already defined. Previously this threw an exception.
(2) Setting the image attribute of a mesh face will also set the TEX bit
of the face.mode flag
(3) When "sticky" vertices are created with mesh.vertexUV, the color is
set to white instead of black.
Three more changes for the Mesh module:
(1) Bug fix for UV vertices ("sticky"). me->msticky was not being updated
when vertices were added or deleted from the mesh.
(2) Vertex, edge and face .extend() methods accept zero-length sequences
instead of throwing an exception. (Note that not giving any argument
is still an error).
(3) Edge and face .extend() methods ignore "invalid" edges or faces which
have the same vertex twice instead of throwing an exception. Cam and I
argued about this for a while... :-)
Python Object API
Allow object.setMatrix() to accept 3x3 matrices by extending to a 4x4 internally. Also check the dimensions of the new matrix and throw an exception if not a 3x3 or 4x4.
Python Dupli access
Log: Applied JMS's Patch. for better Python Dupli Access. Made some fixes and changes. * The matricies returned were wrapped. Wrapping Display Mesh matricies segfaulted sometimes. - Made a copy instead. * Added 1 missing epydoc from the patch. * Renamed getDupliMatrices to getDupliObjects, and changed to return a list of (object, matrix) tuples instead of just the matrix. This is much more usefull because it allows python to know what objects are used for dupliGroups and for dupliverts where there is more then 1 child. also cleaned up this function a bit.
python empties
new emptys now have default settings for new emptys.
Documentation
Taking a hint from Hos, started adding some (hopefully) better examples into the documentation for creating and manipulating meshes.
Beztriple API
Additions to BezTriple API: complete get/set access to all BezTriple settings (knot and handles points, handle types, tilt/alfa, hide, weight and selection status).
Python Mesh API
A bug fix and an enhancement:
* fixed bug when adding or deleting faces from a mesh which has
vertexColors; mesh->mcol was not being updated
* changed edges.extend() and faces.extend() to accept integer vertex
indices in addition to MVerts; this should make scripts simpler and
in general make things run faster
Python
Added Blender.Group module The plans for the new Python API are too far off to have this module conform. Added object.dupliGroup so objects can access the groups they instance. This is very confusing. Since in object has ob.setDupliGroup() # Enable/Disable Dupligroup ob.getDupliGroup() # see if its enabled. ob.dupliGroup # the group data this object is instancing. Not yet added ob.groups # Groups that use this object.
Log:
Added support for group objects
grp.objects
To have an iterator assigned as well as a list. Since gp.objects is an ietartor this is expected.
grp.objects= someGroup.objects works now.
Some other small fixes made.
Made a wrapper for add_to_group() That handles the OB_FROMGROUP flag. Should be moved to group.c's add_to_group()
void add_to_group_wraper(Group *group, Object *ob) {
Base *base;
add_to_group(group, ob);
if (!(ob->flag & OB_FROMGROUP)) { /* do this to avoid a listbase lookup */
ob->flag |= OB_FROMGROUP;
base= object_in_scene(ob, G.scene);
if (base)
base->flag |= OB_FROMGROUP;
}
}
renderpath for python
Added a way to set the renderpath (dir and name) from the command line.
eg
Blender -b c:\blends\test.blend -o "c:\renders\render_#.png" -x 0 -F PNG
-x 1/0 for extension enable/disable
-F for format/filetype
This is important because somebody elses Blend files can render anywhere on your PC, possibly a security risk.
And nice for renderfarms to be able to set the path without running a python script inside the blend file.
blender --help (render opts only)
Render options:
-b <file> Render <file> in background
-S <name> Set scene <name>
-f <frame> Render frame <frame> and save it
-s <frame> Set start to frame <frame> (use with -a)
-e <frame> Set end to frame (use with -a)<frame>
-o <path> Set the render path and file name.
Use // at the start of the path to
render relative to the blend file.
Use # in the filename to be replaced with the frame number
eg: blender -b foobar.blend -o //render_# -F PNG -x 1
-F <format> Set the render format, Valid options are..
TGA IRIS HAMX FTYPE JPEG MOVIE IRIZ RAWTGA
AVIRAW AVIJPEG PNG AVICODEC QUICKTIME BMP
HDR TIFF EXR MPEG FRAMESERVER CINEON DPX
Use // at the start of the path to
-x <bool> Set option to add the file extension to the end of the file.
Added details to the -v option
Eg
blender -v
Blender 2.41 Build
build date: 2006-03-20
build time: 16:16:34
build platform: linux-glibc2.3.6-i386
build type: dynamic
Also fixed bugs where nagative/realy big frames could be set- causing Blender to crash.
Python Docs
Attempted to unify and document Dupli* stuff. DupGroup DupObjects enableDupVerts enableDupFrames enableDupGroup enableDupRot enableDupNoSpeed see the epydocs for documentation at http://members.iinet.net.au/~cpbarton/ideasman/BPY_API/Object.Object-class.html - will update in a tick.
Python
Log: Made blender python work in background mode without a blend file loading. Blender.c python initialization creates a scene when in background mode and when there is no scene. Needed to skip redrawing when in background mode because it depended on screen data that wasnt there.
Python API
Log: Added select group meny to mesh editmode. Currently only works for faces. Try Shift+G in face/editmode.
Python API
Log: Added python image pack/unpack per image.
python
Added matt's empty drawsize property to python.
bpymesh
dded BPyMesh for mesh python mesh functions.
at the moment it only has meshWeight2Dict and dict2MeshWeight
These allow you to deal with vertex weights as a list of dicts which makes scrips short and easy to understand.
(kh_python, perhaps dict access to the python verts could replace this )
Used the above util functions to update mesh_cleanup.
Copied from the source
'Material Clean', 'Remove unused materials.'
'VGroups'
'Group Clean', 'Remove vertex groups that have no verts using them.'
'Weight Clean', 'Remove zero weighted verts from groups (limit is zero threshold).'
'Weight Normalize', 'Make the sum total of vertex weights accross vgroups 1.0 for each vertex.'
Normalizing lets you see how much % of the vertex a bone owns just by looking at 1 of the bone weights.
Would be nice to have this functionality in Blender but theres not much room for new buttons in teh vgroup and material area :/
python API Groups
Added Group to Blender.Types, tested and working. Added Group Epydocs, with 2 examples. also added http://en.wikibooks.org/wiki/Blender_3D:_Blending_Into_Python to the blender links main page.
python api
Replaced constant_getAttr() with constant_getAttro(), and added extra code so that the .keys(), .items() and .values() methods worked.
Python API
New Ipo and IpoCurve API. Ipo and IpoCurve objects support the [] operator, for accessing the curves of a particular Ipo and for accessing the value of an IpoCurve at a specific time. Both modules were also "tp_getset"-ified. Also, code for an alternative method (Antont wanted this) of accessing curves via Ipo attributes is included for now, for people to try and see if it's actually preferable to the Ipo [] operator. These are all new additions; nothing was intentionally removed from the API. If you find the something in the existing API has changed, let me know.
Python API
Initial commit for new Modifier API. Probably does about 70-75% of what it should, but it's a start.
modifer sequencer python
Log: added remove to the modifier seq (when pymodifier->md is NULL then its been removed) added name to the docs
Python API
More Modifier API changes: * add Blender.Modifier.Settings dict with constants for modifier types * add mod.type attribute, which returns type of the Modifier * add some internal consistency checks in ModSeq_remove
python modifiers
Re arranged how modifiers are used. All settings through Blender.Modifier.Settings see the epydocs Also added some error checking to fix some possible segfaults. Added more epydocs Modifiers API should be stable enough to use now, though give it a bit of time for testing.
Mathutils
Added scalePart to mathutils matrix type object.
and made it so toEuler converts a 4x4 matrix to a 3x3 rather then raising an error.
Its not straight fwd to get an objects worldspace loc/size/rot from its 4x4 matrix.
Example from updated docs.
import Blender
scn = Blender.Scene.GetCurrent()
ob = scn.getActiveObject()
if ob:
mat= ob.mat # Same as martixWorld
print 'Location", mat.translationPart() # 3D Vector
print 'Size", mat.scalePart() # 3D Vector
print 'Rotation", mat.toEuler() # Euler object
Python API
Added render.getRenderWinSize() method, to complement render.setRenderWinSize()
pydrivers
Pydrivers: Ipo Drivers controlled by Python expressions
wiki with info: http://mediawiki.blender.org/index.php/BlenderDev/PyDrivers (there are two sample .blends in the patch tracker entry, last link in the wiki page) Notes: In usiblender.c I just made Python exit before the main library gets freed. I found a situation with pydrivers where py's gc tried to del objects on exit and their ID's were not valid anymore (so sigsegv). Ton needs to check the depsgraph part. For now pydrivers can reference their own object, something normal ipodrivers can't. This seems to work fine and is quite useful, but if tests prove the restriction is necessary, we just need to uncomment a piece of code in EXPP_interface.c, marked with "XXX". Thanks Ton for the ipodrivers code and adding the hooks for the py part and Martin for the "Button Python Evaluation" patch from which I started this one. Anyone interested, please check the wiki, the .blends (they have README's) and tell me about any issue. Small update for pydrivers: force reloading the pydrivers.py Blender text module when user edits the input text box of any pydriver (Transform Properties panel, Ipo window). It's enough to click in and out of a single pydriver's text input box for the module reloading and also re-evaluation of all pydrivers available. Maybe this "refreshing" should also be available from a menu, let's see. Note for Python fans: Definitions and redefinitions in a reloaded module are properly handled in Python, but previously defined data in the module doesn't disappear. So if you define a function "f" inside a module, import it, then change the function's name to "g" and reload the module, both "f" and "g" will be available. This is considered a feature, check reload's documentation: http://docs.python.org/lib/built-in-funcs.html#l2h-59
Python API
Added activeGroup attribute to Mesh API, to get/set active vertex group for meshes.
python api
added optional 'worldspace' arg to getLocation/getSize/getEuler getSize is never flipped, but added a note in the docs. correction to getEuler, its not wrapped. also removed all // comments to shut GCC up.
python
Added "VertexPaint" slot for python menus
Python API
New Constraint API. Constraints are accessible through a "constraints" attribute in poses and objects. Would be REALLY NICE for armature users to pound on this code.
mesh python api
Added some shortcuts to Mesh MFace.area MFace.cent MEdge.length Updated some scripts that used these.
Mesh API
Log: Added MVert.hide property because hidden verts were hanging BPyMesh_Redux
==Python API== Added NULL constraint (and fixed bug that didn't allow appending FLOOR constraint), and added support for Constraint.Settings.LOCAL key support in COPYLOC, COPYROT and COPYSIZE constraints when target object is an armature.
Python API
* use CONSTRAINT_LOCAL instead of SELECT in "Copy Rotate" constraint * remove "LOCAL" key for now from "Copy Size" constraint; not supported right now in Blender UI
Python API
Make me.faces.sel and me.edges.sel behave like EM_select_face() and EM_select_edge() in source/blender/src/editmesh_lib.c. Script users should note that if they change ANY of the selection states (vertex, edge, face) and then call a mesh "tool" method (like me.remDoubles) that the selection states of the mesh MAY change, since these tools use the edit mode (which updates select states).
pose api
*applying patch [ #4143 ] Methods for reading bone movement limits Aron Cristian (criller) Gives the ability to return/set the limitations on a posebone when that bone is part of an IK chain.
2.41 Release
Added Tools
Mesh sculpting (Mesh Menu)
Usage - select from the Mesh Scripts menu in edit mode
http://mediawiki.blender.org/uploads/3/34/BBrush_sculptor_mesh_menu.png
You will get a popup telling you how to enable it, this menu is a message none of the items are active.
http://mediawiki.blender.org/uploads/9/94/Release_241_BBrush_usage_dialog.png
Then go to the view menu and enable the script
http://mediawiki.blender.org/uploads/c/ce/Release_241_BBrush_enabling_spacehandlers.png
Press the Left Mouse Button to sculpt. Press the Right Mouse Button to select your sculpting options
http://mediawiki.blender.org/uploads/8/89/Release_241_Bbrush_panel_tooltips.png
use the SHIFTKEY to have the sculpting use a negative pressure.
Notes
Make sure that you have a somewhat subdivided object. If the faces are large relative to your brush size it may appear that it doesn't work.
Tools
- push/pull - sculpts a bump with a fall off on the mesh. Use static mesh to paint a ridge of a fixed size.
- grow/shrink - moved verts away or towards the mouse, use a low pressure for subtle results.
- spin - Rotate about the normal using the mouse point as a center, and the brush size as a radius.
- relax - Move verts to make surround faces less skinny.
the pressure needs to be fairly high to be able to notice an effect - goo - Drag a part of the mesh as if its liquid rubber.
Use a pressure of 1.0 and static mesh disabled for expected results.
Some examples below-
http://grzybu.com/images/3d/current/tron_20051220_web.jpg
credit: Grzegorz Rakoczy - throne
http://img436.imageshack.us/img436/2117/bakteria032xn.jpg credit: Jedrzej_s and brother - bacterium
http://static.flickr.com/40/84281937_851917e81b_o.jpg credit: maamqqq - metaball workflow
http://mediawiki.blender.org/uploads/6/61/Py_release-notes_2_41_Bbrush_example.png credit: Campbell Barton
Made entirely in bbrush from a subsurf cube, no manual editing.
Triangles to Quads (Mesh Menu)
tri2quad script finds all possible quads to be made from selected triangle pairs, then joins the best first until the error limit is reached.
Updated Tools
Archimap Projection Unwrapper (UV Menu)
http://mediawiki.blender.org/uploads/f/f7/Archimap_eg.png
Fixed a bug in boxpack that archimap not to clear data between uses, and become progressivly slower.
Updated Archimap to set UV's aslists (dont need to convert to tuples anymore)
- Added PupBlock for user options.
- Improved context, unwraps active object if not selected and makes sure it only unwraps a mesh once even if 2+ instances are selected.
- Added Option to stretch to bounds
- Added option to have a margin, thanks to letterrip
- Fixed bug when assigning UV's to zero area faces.
Mesh Cleanup (Mesh Menu)
Renamed clean_mesh.py to mesh_cleanup.py
Rewrote to use Kens Mesh module, much faster, cleaner and nicer UI. - Another use for PupBlock.
tex2uvbaker (UV Menu)
hotkeys update by jms
Apply Deformation (Mesh Menu)
Log: Fix for useing with modifiers, dosent check for subsurf flag when copying vgroups.
Leaves all new objects selected.
Faster and cleaner operation- naming etc.
Bevel Center (Mesh Menu)
updated version of bevel center by Loic Berthe
Batch Object Name Edit (Object Menu)
Fixed bugs when working with empty objects.
Use new Mesh module so data names can be changed without flushing the NMesh.
Use PupBlock so every action only uses 1 popup.
POSE
Python Pose Module
Log:
- pose code for python
- adds object.getPose - ability to manipulate poses /posebones - fixes a overflow bug in matrix sequence accessor - adds code to get vec/roll from mat3 - few internal fixes to NLA - ability to set bone matrices
Mathutils
Python Mathutils fix
Mathutils fix: bug #3737 Vector.resize4D() didn't put 1 in the 4th component (the scale factor), as it did in 2.37. While this is more "correct", it is much less usefull. Also, matrix.resize4x4 puts a 1 there too, so might as well revert and be consistent.
Mathutils
[ #3661 ] resize4x4 in Matrix class doesn't set ones on the diagonal
- resizing a matrix now puts 1's back on the diagonals.
ARMATURE, BONES and CONSTRAINTS
bugfix: #3738 BonesDict was returning None instead of throwing a KeyError when key not found. Also fixed a few compile warnings about struct initialization.
[ #3712 ] Calling makeEditable() and update() on an armature twice duplicates bones
- fixes bug where editbones are not freed on calling update()
- bone.children fix
- fixes bone.children to return direct bone children - added bone.getAllChildren() to allow previous behavior
bug fix constraints
Bugfix as provided by 'stealth apprentice' on the bf-comitters list. Function get_constraint_target() should catch the case when a constraint has unknown type, to prevent a pointer to become unitialized.
BEZTRIPLE
Python Beztriple fixes
Log: Removed printfs in setPoints(), add proper exception handling.
Window
Window Editmode fix
Fixed Window.Editmode(0) so that it only calls undo_push_mesh() when U.undosteps is nonzero.Also added optional parameter to avoid pushing undo info alltogether if desired.
Window Theme
- minor: added missing theme options (bone_solid, bone_pose, strip, strip_select) to Blender.Window.Theme and also updated accordingly (version info) the script that saves themes as scripts and the module's doc.
IPO
IPO.getKey
Log: Patches submitted by Michael Reimpell to get/set relative key selection, and to get the current value of the IPO shape key.There are still some issues to discuss as to whether methods/attributes should be used and what they should be named, but this will (or should) be addressed in the upcoming API rewrite.
OBJECT
Object.Get
replaced more M_Object_Get for the faster Object_CreatePyObject. Object.GetSelected now dosen't return None if there is no 3d view. - wasn't documented and likely would mess up scripts that always expected a list. - Just return an empty list instead.
Object.GetSelected
Added some notes regarding Object.GetSelected() - it uses the last localview.
Object.insertShapeKey
patch from jean-michel soler (jms) - .insertShapeKey()
Python API, a function to insert a shape key in an object . It works on Mesh, Lattice curve ans surface . Example of use :
import Blender
OBJECT=Blender.Object.GetSelected()[0]
OBJECT.insertShapeKey()
Object fix
Object.Get( name ) was throwing an AttributeError. Change to throw more correct ValueError
Object.Join
Added a python hook to Joining objects Object.Join()
Seperated the join calls from space.c and view3dmenu into join_menu() in space.c, like the select_group_menu(), okee's from join_curve, join_mesh.. etc are in join_menu() so python can call them without UI menu's in the way. this is also a bit neater since there were 2 places that were doing what join_menu() does now.
Moved Object.Join() into a function of an object. eg. ret_val = ob.join(objects) Now it dosent depend on the current selection, or change the selection context.
Made respective join_* functions return 0 if the join was not mode, 1 when it workes.
Object.insertPoseKey
added Object.insertPoseKey to continue with the attempt to make nla/path walkcycle baking to actions
Object.Duplicate
Added the function Duplicate to the object module. Object.Duplicate(linked=1)
Basicly a wrapper for adduplicate();
There was previously no easy way to copy objects in python. even the ways that do exist dont take modifiers, particles etc into account. Uses the current selection
Changed adduplicate() to take the dupflags as an argument. so faking the Alt Key isnt needed anymore in Blender or python. Changed Pythons Object.Duplicate() to take keyword parms to enable duplication of spesific data. Eg- Object.Duplicate(mesh=1) # to duplicate mesh data also.
Made pythons duplicate not redraw, documented adduplicate()
Mesh
Mesh_getFromObject made Mesh and Surf types copy the material list to the new mesh. Still need to do Mball and Text.
Blender.Mesh.Mode
Python Mesh bugfixes
Bugfix #3761: Attempting to set mesh.faceUV=1 when a mesh has no faces now throws a RuntimeError exception.Previous behavior was to do nothing.
- edge and face extend() methods now add edges and faces in the order given
by their parameters.Note that if duplicate edges or faces are specified, the order is preserved but the dups are removed, so indices won't match.
- allow extend(), findEdges() and faces.uv to accept lists or tuples
- fix bug in mesh.verts.extend() which didn't correctly check argument types
Two bug fixes for mesh.faces.extend() method; fix a error checking for duplicate faces in the input list, and also extend texture faces if they are enabled.
Clean-up of some reference counting issues with delete() methods.Also further relax the input types for edge.extend() and face.extend() so that single lists or tuples are accepted without errors.
Another bug fix for reference counting in extend methods.
Cam Barton discovered the setter for me.faces[i].col was missing.
NMesh
Created local function check_NMeshLists(), which performs checking on NMesh lists before trying to build a new mesh (used by mesh.PutRaw() and mesh.update()).It was possible to put junk into the NMesh lists, resulting in some messed-up meshes.
MISC
Bug fix #3671: Blender.Beztriple.New() did not accept sequences as parameters, even though its error messages suggested it did. Thanks to Yann for the patch (I also added the ability to accept parameters without requiring them to be in a tuple). Also documented the New() function.
Bugfix #3652: material.setSpecCol() only accepted a tuple, not separate parameters as it used to (prior to my tp_getset update).Fixed this and other similar situations.
IPO.addCurve
Bugfix for Toni: Ipo_addCurve() needed to call set_icu_vars() in order to properly initialize data for new Ipo curves.
bugfix
Fixed bug in convert function with Mesh objects. Objects with no modifier could still be converted, but resulting meshes were corrupt and segfaulted Blender when cycling edit mode. This tests each mesh object for modifiers before converting.
Resulting metaballs meshes were not visible in wireframe.
Also made the selection context nicer, All new converted objects are selected while objects that are converted are deselected.
Scene.getChildren
made scene.getChildren() a heap faster. 983.3 times faster in my test. getting 7200 objects did take: 1.18 sec,now 0.0012 sec
It was doing a full object list lookup for every object in the scenes base using the name to compare. now it just gets the object directly from the base and converts it to a python object, adding it to the list.
Curve doc fix
Log: Bugfix #3731: User reported that cyclic IPO curves reported the wrong value in the BPy API for the "end point".It was a minunderstanding of what happens with cyclic Ipos, but we updated the documentation to make this clearer in the future.
lamp modes
Gave an example of changing lamp modes in epydocs.
command line script bug fix
Log: Bug #3658 reported by Daniel Holtz (thanks): http://projects.blender.org/tracker/?func=detail&atid=125&aid=3658&group_id=9
Running scripts from command line in bg mode: blender -b -P myscript.py crashes Blender 2.40.
The problem is in add_text() in text.c: G.scene can be NULL at this point (in bg mode). Added a check:
line 323: if (G.scene) /* can be NULL (bg mode) */ BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
The text being added with add_text() in this particular case is the script filename specified at the command prompt, so it should be ok to skip BLI_convertstringcode. Feel free to disagree, though.
CleverNumButs
PupBlock method. This wraps the "clevernumbut" code to allow scripters to use popup blocks for user input instead of a sequence of multiple different popups. See the blend file for a comprehensive test and example file.
Made buttons in clever numbuts align. Commented out crufty name spesific actions that changed variables and added a label of buttons started with "Rot" - Since panels are used for rotating now.
Exclude labels from grouping. - Clever numbuts look nicer with rounded theme.
Fixed bug in do_clever_numbuts not displaying tooltips. Comment: Clear all events so tooltips work, this is not ideal and only needed because calls from the menu still have some events left over when do_clever_numbuts is called. Calls from keyshortcuts do not have this problem.