Notifications
Clear all
[Closed] Create an Ik Chain – what I am missing?
Page 2 / 2
Prev
Aug 07, 2013 8:40 pm
I really appreciate your help.
It works like a champ now! And as a result, my script is much more simplified compared to what I had at the begining.
Here is the result:
fn createIkChains sel =
(
maxops.CloneNodes sel expandHierarchy:true cloneType:#copy newNodes:&chain
chain.wireColor = (color 196 88 225)
for bone in chain do
(
bone.width += 1.5
bone.height += 1.5
bone.name += "_IK"
IkHandle = IKSys.ikChain bone bone.children[1] "IKHiSolver"
-- format "IkHandle: %
" IkHandle
IkHandleName = ("IKChain_" + (substring bone.name 1 (bone.name.count-3)))
if IkHandle != undefined then IkHandle.name = IkHandleName
)
)
createIkChains $
The only question that remains is this weird thing that “IkHandle” gives me… on the second occurrence of the loop, it always output undefined. If you un-comment the format line, you’ll see what I mean.
I had to add a check on IkHandle to rename it only if its not undefined.
Aug 07, 2013 8:40 pm
Hey David,
That's because it is the last bone in the chain and it has no children.
format "IkHandle:% bone:% children:%
" IkHandle bone.name bone.children[1]
I have updated your function to avoid undefined children:
fn createIkChains sel =
(
maxops.CloneNodes sel expandHierarchy:true cloneType:#copy newNodes:&chain
for bone in chain where (children = bone.children[1]) != undefined do
(
IkHandle = IKSys.ikChain bone children "IKHiSolver"
IkHandle.name = "IKChain_" + bone.name
)
chain.wireColor = (color 196 88 225)
chain.width += 1.5
chain.height += 1.5
chain.name += "_IK"
return chain
)
Aug 07, 2013 8:40 pm
Thats great! It works very well.
That’s because it is the last bone in the chain and it has no children.
That is what I was thinking, just not knowing why it always occurs at the second occurrence in the loop instead of at the last one.
I like the way you di it. I makes me see how much I still have to learn to write better scripts :D.
Like this part, I would never have thought of doing it this way:
for bone in chain where (children = bone.children[1]) != undefined do
I would probably had come up with this:
for bone in chain do
(
if bone.children[1]) != undefined then
(
IkHandle = IKSys.ikChain bone children "IKHiSolver"
IkHandle.name = "IKChain_" + bone.name
)
)
You see how your way is definitely better than mine ;).
Thanks
Page 2 / 2
Prev