Notifications
Clear all

[Closed] adding rotation controller to the controller list via script

having trouble adding a rotation controller to the controller list via script.
I have typical 3 chain IKFK bones, select the deformation bones, and run this script:


for each in $ do(
	local DEF_name=each.name
	local IK_name=substituteString DEF_name "DEF_" "IK_"
	local FK_name=substituteString DEF_name "DEF_" "FK_"

	local DEFobj=execute ("$" + DEF_name)
	local IKobj=execute ("$" +IK_name )
	local FKobj=execute ("$" + DEF_name)

	local rc = orientation_constraint()
	rc.appendTarget FKobj 50.0
	rc.appendTarget IKobj 50.0
	DEFobj.rotation.controller = Rotation_list()
	DEFobj.rotation.controller.available = rc --this seems to be the problem
	)

get this error:

– Unable to convert: Controller:Orientation_Constraint to type: Quaternion

I am able use mxs to to completely replace the list with an orientation constraint, but that is not what I wish to do, as subsequent scripts will break.

5 Replies

That is because you are trying to set the value of the available controller. To assign a new controller you have to set the DEFobj.rotation.controller.available.controller = rc.

-Eric

hmmm… doesn’t quiet do the trick.
No errors, but the controller it adds looks like a second Euler controller, named “Available”.

I’m trying to add an orientation Constraint.

Perhaps I need to somehow add a Sub Anim?

In essence I am trying to replicate precisely the resulting controller configuration that you get when you manually assign an orient constraint to an object via the animation menu.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

what can be easier? just look in mcr file and get how they do it. that was one of resources that helped me to learn ‘rig scripting’.

If you are trying to add Orientation_Constraint via script then you can do it this way. where $[1] (first obj selected) is the object you want to constraint and $[2] (second object selected) is the object you want to constraint it to.


$[1].rotation.controller = Rotation_list()
Oc = Orientation_Constraint()
$[1].rotation.controller.available.controller = Oc
orientConstraint = Oc.constraints
orientConstraint.appendtarget $[2] 100

Let me know if that helps. I also agree with Denis looking at the .MCR in max will take a long way at figuring out how some things are done in max via script.

thank everyone for the help.

It never occurred to me that much of the buttons in MAX would have associated .mcr files, thanks for the tip.
I assume Macro_Constraints.mcr is the script I should examine in this case.
Unfortunately the relevant command to orient constraint looks like this:


on execute do ( AssignConstraintSelection Orientation_Constraint ~ORIENTATION_CONSTRAINT_ROTATION~ Rotation_List ConstrFilterFn ~CONSTRFILTERFN_PICK_OBJ_CAPTION~ ~CONSTRFILTERFN_ORIENTATION_CONSTRAINT_CAPTION~ )

which is no more clearer than the max script help files
nor does it look like anything I can make functional.
I’m not even sure what ~TEXT_LIKE_THIS~ represents ( tho I suspect it’s constants for localized interface text).

here is what worked for me:



$.rotation.controller = Rotation_list() --converts rotation controller form Euler XYZ to list, adds EulerXYZ to that list
$.rotation.controller.available.controller=orientation_constraint() --adds orient constraint to the list
$.rotation.controller.setactive 2 --otherwise, EulerXYZ was active
$.rotation.controller[#Orientation_constraint].appendTarget $Bone001 50 --($.rotation.controller[2] would also work, but I like to keep things clearer)


My trouble seems always to arise from not understanding how to correctly target the constraints / controllers / subanims.
I’m used to the simplicity of Maya/Python object.property
versus Max’s more obfuscated (to me) object.controller.controller_type.list_controller_thingy.sub_anim_thingy.property