Script to create custom bone shapes inheriting bone loc/rot?

In Autodesks’ maya most professionals use a script/addon for creating custom shapes for controlling joints when rigging. I myself use this https://www.creativecrash.com/maya/script/mz_ctrlcreator
It works this way:
You select a joint (bone) in the armature, the software reads it’s location and rotation and creates an object of your choice with those attributes.

I have been trying to rig a character in Blender. I might be doing this the wrong way, trying to rig like I do in maya, but I really need a script for Blender that achieves the same result. Making custom bone shapes is a pain when having to rotate them to match the bone, when I think it could easily be done automatically.

Have anyone heard of a Blender addon like this? If not, would it be possible to have it coded? I am working a freelance job right now, and it would greatly speed up my workflow.

Cheers.

If you select an armature, then bones have constrictions.
You could.
Snap cursor to the selected bone.
Add an empty cube, or some custom shape Spline.
Then in the bone constraint, you can tell the bone to copy rotation from the empty.
Now the bone rotates as the empty.
Next you can add to the empty also a constrain, to copy the location of that bone. and then they stay in place

but above is a poremans solution to rigify, using rigify is a much easier way to get a (fixed prestructured bone system) into a character.
Rigify creates an armature, which you then have to pose like your figure and then with automatic weight painting aply it.
i think its possible to even add or remove bones from rigify but ive not done that.

Razorblade, I agree on part of what you have said. I had not thought about being able to copy the rotation of the bone using the copy rotation constraint, but this works perfectly!

This is a simple way to achieve a perfectly lined up custom shape object to bone:

  1. Select bone in Pose mode
  2. Shift+S cursor to bone
  3. Shift+A add custom bone object to scene (Do not make it fit your character just yet)
  4. In the custom shape object in Constraints add a Copy Rotation constraint and point it to the bone in the armature you previously selected
  5. Ctrl+A apply ‘Visual Transform’
  6. Delete previously added Copy Rotation constraint from custom bone object
    (6-2.) Shape your custom bone object to fit your character, making sure not to change object attributes
  7. Select your bone and under Bone properties > Display set your custom bone object as custom bone shape and un-tick ‘Bone Size’

That’s it.
Now I just need to find a way to automate this process.

But thanks for helping me finding this solution, Razorblade!
Reason I am not using rigify is because I am rigging a creature :slight_smile:

Cheers,

Oh well, yeah its a repeatitive handling
To get some coding clues, drag down bottem line of the top menu bleu (i), it logs all action one performs as python code.

I myself am also thinking about bones and movement right now, i’d like to make a walk solver. (scripted walking)
I’m no expert either, i kinda know what i want to make but i am not so used to writing python (im more in c# c++).
So i’m glad i could help you there.

PS you did know rigify ?. (its a blender addon, to rig a human quickly).

I will be resurrecting this thread because I just started programming the script since I recently started learning python.

So far this is what I have:


import bpy

get name/location info on active pose bone

obj = bpy.context.active_pose_bone.name
loc = bpy.context.active_pose_bone.matrix.to_translation()

create control object

bpy.ops.curve.primitive_bezier_circle_add(view_align=False, enter_editmode=False, location=(loc), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))

copy rotation of active pose bone to controller object

bpy.ops.object.constraint_add(type=‘COPY_ROTATION’)
bpy.context.object.constraints[“Copy Rotation”].target = bpy.data.objects[“Armature”]
bpy.context.object.constraints[“Copy Rotation”].subtarget = obj
bpy.ops.object.visual_transform_apply()
bpy.ops.object.constraints_clear()

convert controller object to MESH

bpy.ops.object.convert(target=‘MESH’)

move controller object to layer 2

bpy.ops.object.move_to_layer(layers=(False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))

rename controller object

bpy.context.object.name = “CTRL_%s” % obj

make custom shape on active pose bone

bpy.context.object.pose.bones["%s" % obj].custom_shape = bpy.data.objects[“CTRL_%s” % obj]
bpy.context.object.pose.bones[“Index02.L”].use_custom_shape_bone_size = False
bpy.context.object.data.bones[“Index02.L”].show_wire = True


I am having some issues with the last part of the script.
how do I activate the armature again so that I can connect the custom shape to the pose bone? after creating the controller object and renaming, blender can’t find the pose bones of the armature because (as I read it) the armature is no longer active.
Am I misunderstanding this? how can I make this work?

thank you