Maya – Python – Tentacle Auto-Rig

These series demonstrations will illustrate how to build a simple FK tentacle rig using scripted fundamental processes with python.

They will guide the learner through scripting, automated fundamental rigging procedures with the ultimate aim to creating a reusable tentacle rig tool.

 

  • Part1
  • Part 2
  • Part3

Rename Python Script

import pymel.core as pm

jointArray = pm.ls (sl=True)

#description strings
assetName = "Tentacle"
assetType = "Character"
description = "Arm"
objType = "skinBone"
divider = "_"

for i in range (0,len(jointArray), 1):
    pm.rename ("joint" + str(i+1), assetName + divider + assetType + divider + description + str(i+1) + divider + objType )

Create controller shapes that will align to joints

import pymel.core as pm

#array list
jointArray = pm.ls (sl=True)
CTRLArray = [] #This is a blank array that will hold the CTRLs

#description strings
assetName = "Tentacle"
assetType = "Character"
description = "Arm"
objType = "skinBone"
divider = "_"

#rename joints
for i in range (0,len(jointArray), 1):
    pm.rename ("joint" + str(i+1), assetName + divider + assetType + divider + description + str(i+1) + divider + objType )
    
# create CTRLs
for i in range (1, len(jointArray), 1):
    CTRL = pm.circle (name = assetName + divider + assetType + divider + description + str(i) + divider + "_CTRL", ch=False)
    CTRLArray.append (CTRL) #This will place the new control shape into the blank array
    ConstrainCTRL = pm.parentConstraint (jointArray[i-1],CTRL, mo=False) # mo=False so CTRL shape moves to joint
    pm.delete (ConstrainCTRL) #constraint no longer needed
    pm.makeIdentity (apply=True, t=True, r=True) #apply to translation and rotation of CTRL


Organise and Connect the existing rig

import pymel.core as pm
#parent CTRLs in hierarchical order 
skinBoneArray = cmds.ls(sl=1, o=1) 
CTRLArray     = cmds.ls(sl=1, o=1) 
for i in range (0, len(CTRLArray),1):
    parentObj = -1-i
    childObj = -2-i
    if parentObj !=0:
        pm.parent (CTRLArray[parentObj], CTRLArray[childObj])

#Connect bones to CTRLS
for i in range (0,len(jointArray)-1,1):
    pm.parentConstraint (CTRLArray[i],jointArray[i], mo=True)

This is a unique website which will require a more modern browser to work!

Please upgrade today!