Cannot create IK Controller for existing bone chain?

Cannot create IK Controller for existing bone chain?

ClaudioAlvaro
Contributor Contributor
1,244 Views
10 Replies
Message 1 of 11

Cannot create IK Controller for existing bone chain?

ClaudioAlvaro
Contributor
Contributor
I'd like to confirm that creating an HI ik controller for an existing chain of bones cannot be done through Maxscript. The IKControl class returns "-- Runtime error: Not creatable: IKControl" if I attempt to create an instance. There is also very little documentation around accessing and manipulating IK controllers.

Any info or workarounds would be greatly appreciated.

CL Audio
---
3DSMax 2012 SP2
0 Likes
1,245 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
You can actually create IK chain's but it is somewhat burried in the docs.

IKSys.ikChain selection selection "IKHiSolver"

Look op IKSys interface in the manual... interresting to note, "showinterface IKSys" shows more options for IKSys then the manual does...

-Johan
0 Likes
Message 3 of 11

ClaudioAlvaro
Contributor
Contributor
Much appreciated, Johan - that did the trick. On a side note, because we're on a subscription we haven't had hardcopy manuals since version 6 of 3dsMax.

Thanks again.
---
3DSMax 2012 SP2
0 Likes
Message 4 of 11

Anonymous
Not applicable
Glad it worked!

I was under the impression that since max7 they don't do printed manuals no more. I could be wrong though. I always use the maxscript help file under help... works faster for me then the manual.

-Johan
0 Likes
Message 5 of 11

Anonymous
Not applicable
I'm sorry but i didn't get the same ease into a successful production as Claud...Johan

In my attempt, I created the selection set:-

----select bones for IKchain
select $BoneHip --- for my start joint
Selectmore $BoneAnkle ---for my endjoint



Then added your script:-
Ik Chain01 = createIKChain selection selection ikType:"IKHISolver"



The result is:-

-- Type error: Call needs function or class, got: undefined
-- Runtime error: operation requires a collection of nodes, got: undefined


Of cause yours is a little different from that in the manual which is:-

----<node>ikChain <node>startJoint <node>endJoint <string>solver


However all is not lost, because this one does work:-

HDIKSys.ikChain $Bonehip $BoneAnkle TRUE


Only its not for the "HI_IK" IKsolver.

Ofayon 😉
0 Likes
Message 6 of 11

Anonymous
Not applicable
I see you have a space between "IK Chain01" a variable cannot have spaces in it. So try Ik_Chain01 or IkChain01, now max thinks you're calling the Ik function with the Chain01 variable... which both don't exist and return undefined.

Hope this helps,
-Johan
0 Likes
Message 7 of 11

Anonymous
Not applicable
Hello Johan,

I’m sad to say, I still am not getting it. I must be missing something,….. somewhere…
Here’s a catalog of the error messages I’ve received, with each command_line.

Ik_Chain01 = createIKChain selection selection ikType:"IKHISolver"

-- Type error: Call needs function or class, got: undefined
-- Runtime error: operation requires a collection of nodes, got: undefined


IKSys.ikChain selection selection “IKHiSolver”

-- Argument count error: ikChain wanted 3, got 2
-- Syntax error: at bad, expected <factor>
-- In line: IKSys.ikChain selection selection “I


Ik_Chain01 = createIKSys.ikChain $boneHip $boneAnkle “true”

-- Unknown property: "ikChain" in undefined
-- Syntax error: at bad, expected <factor>
-- In line: Ik_Chain01 = createIKSys.ikChain $boneHip $boneAnkle “t


Ik_Chain01 = IKSys.ikChain selection selection “true”

-- Argument count error: ikChain wanted 3, got 2
-- Syntax error: at bad, expected <factor>
-- In line: Ik_Chain01 = IKSys.ikChain selection selection “t


The list goes on, I have also attached the whole shebang, .Max file and script as Zip for opinions.

All the best.

Ofayon;)

12925_5UUXm1FLkVsHKt15NES5.zip

0 Likes
Message 8 of 11

Anonymous
Not applicable
Hi, by looking at your script, the error comes from bad double Quotes Character

IKSys.ikChain selection selection "IKHiSolver"


changing those makes the script run OK
0 Likes
Message 9 of 11

Anonymous
Not applicable
Hi everyone,

First of all, all my thanks for your help with adding the Ik controllers to the script.
I have to admit having gotten that far, it felt kind of like an itch, I couldn’t scratch.
But then following that. I have moved on to adding Custom Attributes and Perimeter Wiring to the script now.
I can’t say it hasn’t been without hiccups.
For one, scripting the creation of a Custom Attribute. Seems a little more involved than it first appears.
But I have found the whole exercise, thoroughly satisfying.
Further, I for one cannot understand, why there isn’t a tutorial project within the Max help, to do just that.
Maybe the whole thing gets lost in the works, when deciding if the Tut.,
"should be placed in ‘Maxscript reference’ or ‘3dsMax tutorials.’"

Ofayon

Attached is my last script update and Max file.

13041_umCrJfzurqCQWSvHDv1N.zip

0 Likes
Message 10 of 11

Anonymous
Not applicable
For automation take a look at the code below. It does in a few lines what half your script takes to do.
You don't have to select objects in the scene to do stuff to it.
This code below sets the bones for the leg, renames and parents them, out of only the legs array... if you named your points with the names of the joint they represent you wouldn't even need the extra name in the array.


bonePrefix = "Bone"
legs = #(#($point06,"Hip"),#($point05,"Knee"),#($point04,"Ankle"),#($point03,"Toe"),#($point02,"ToeTip"),#($point01,""))

for i in 1 to legs.count - 1 do
(
b = BoneSys.createBone (legs).pos (legs).pos
b.name = BonePrefix + legs

-- try to parent to previous will fail on first bone
try
b.parent = getNodeByName (BonePrefix + legs) -- lets try to get the bone by name definition
catch
format "% couldn't be parented\n" b

)


About the custom attribute you should pass the variable that holds the CA not the CA name so in this case:
custAttributes.add $CtrlFoot Ctrlfoot
since ctrlFoot is where the CA is referenced too... the CA name is "roll".
I always give the var and the ca name the same value like so "myCA = attributes myCA" I now have a reference with the same name as the CA.

Hope this helps you a bit further on this great maxscript journey in the sub-Sahara 😉

-Johan
0 Likes
Message 11 of 11

Anonymous
Not applicable
You know, there are a number of reasons why this scripting exercise is good.
Another other is, it allows a fairly novice scripter.
To look at using FBX transform of Biped to bones and then after tweaking the imperfect FBX transfer,
script the controllers and wiring.

Allowing you to animate one character in both BVH and pose to pose...!

Ofayon 😉
0 Likes