From 97002c2d90bb067d9e5b7cd592619bf388950a48 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 31 Jan 2011 11:19:23 +0000 Subject: Bugfix [#25876] bpy.ops.constraint.childof_set_inverse has no effect This was a two-part bug: a user error + API error. * User Error: before calling bpy.ops.constraint.childof_set_inverse() for a constraint defined on a bone, you firstly need to explicitly make that bone the active bone. To do that, you do armature.bones.active = posebone.bone # or something similar * API Error: active bone setting was a bit too strict. It only allows setting the active bone if the new bone comes from the same armature, but was overlooking the fact that RNA pointers may have been created through the object using the armature instead. --- source/blender/editors/object/object_constraint.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 344c2c13861..f695f112bc0 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -531,11 +531,20 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int bPoseChannel *pchan= get_active_posechannel(ob); if (pchan) list = &pchan->constraints; - else + else { + //if (G.f & G_DEBUG) + //printf("edit_constraint_property_get: No active bone for object '%s'\n", (ob)? ob->id.name+2 : ""); return NULL; + } + } + else { + //if (G.f & G_DEBUG) + //printf("edit_constraint_property_get: defaulting to getting list in the standard way\n"); + list = get_active_constraints(ob); } con = constraints_findByName(list, constraint_name); + printf("constraint found = %p, %s\n", con, (con)?con->name:""); if (con && (type != 0) && (con->type != type)) con = NULL; @@ -645,8 +654,11 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) bPoseChannel *pchan= NULL; /* despite 3 layers of checks, we may still not be able to find a constraint */ - if (data == NULL) + if (data == NULL) { + printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : ""); + BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse"); return OPERATOR_CANCELLED; + } /* try to find a pose channel */ // TODO: get from context instead? -- cgit v1.2.3