test

import maya.cmds as cmds

cmds.select(hierarchy=True)

selected_hierarchy = cmds.ls(sl=True,transforms=True)

Rename_Col = []

Parent_Col = {}

Count = 0

for i in selected_hierarchy:

if cmds.nodeType(i) != "joint":

parent_Node = cmds.listRelatives( i, parent=True )

pos = cmds.xform(i,ws=True,q=True,t=True)

rot = cmds.xform(i,ws=True,q= True,ro=True)

Obj_name = str(i)

cmds.select( d=True )

Joint = cmds.joint(n="Tt_Joint_"+Obj_name,p=(0,0,0))

cmds.setAttr(Joint+".translate",pos[0],pos[1],pos[2],type="double3")

cmds.setAttr(Joint+".rotate",rot[0],rot[1],rot[2],type="double3")

Count =+ Count+1

if parent_Node == None:

Parent_Col.update({Joint: "None"})

else:

Parent_Col.update({Joint: parent_Node})

#cmds .delete(selected_hierarchy)

for key, value in Parent_Col.items():

print value

print key

if value == "None":

continue

else:

continue

#cmds .parent(key,value)

#for obj_i in Parent_Col:

# Rename_Obj = obj_i.replace("Tt_Joint_", "")

# cmds.rename(obj_i, Rename_Obj)