MAXScript Script Controller Exception

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  10 October 2003
MAXScript Script Controller Exception

When I open comet rigg I get this dialog(but I can not find errors in the rigg after that):

"MAXScript Script Controller Exception"
! -- Runtime error: Illegal self - reference in controller script

and other dialog after that with button Evaluete and Close:

"Script Controller:"

dependsOn $'char_handLCTRL' $'char_elbowLCTRL';


-- Wrap this in a cA.get to make sure we have CA's now.

-- Otherwise on a load or merge, 3dsMAX might try to execute

-- this before the CA's get loaded in! This way it waits until

-- everything is fully loaded before -really- calculating.

myD = custAttributes.get $'char_handLCTRL'.Attribute_Holder 1;

if (myD != undefined) then



-- This script takes two helpers on the wrist to get a

-- local hand "Y" vector, and then unrotates it

-- by the rotation on the lower arm.

-- This way the hand vector is now aligned to the

-- coordinate space of the lower arm.

-- At that point I can get what would be the rotation around

-- the lowerArms X axis using the Y axis as reference

-- (using Y means Y is still correct even if it rotates

-- up/down on the Y axis causing the Z to move)

-- Because we've rotated the hand's world space rotation

-- back by the lower arm readers rotation, this all

-- works in the coordinates of the lower arm, thereby

-- giving us proper values, even though the hand

-- is not in the hierarchy.

-- Using simple trig (SOH CAH TOA) we can get the angle

-- of the twist.


coordsys world


-- Get rotation in world of lower arm

rotStart = $'char_lowArmReaderLINT'.rotation as eulerangles;

-- where is our wrist axis at?

posEnd = $'char_wristReaderLINT'.position;

-- Get our Y axis for the wrist in world

endY = $'char_wristReaderYLINT'.position - posEnd;

-- Normalize our wrist axis

endY = normalize endY;


-- Everything is now normalized for the wrist, so

-- all we have to do now is unrotate by the upperArm angles

-- Make rotation matrices

rotMatX = rotateXmatrix rotStart.x;

rotMatY = rotateYmatrix rotStart.y;

rotMatZ = rotateZmatrix rotStart.z;

rotMat = rotMatX * rotMatY * rotMatZ;

-- Now rotate our Y axis Vector by each x y z of the lowerArm we got

endY = endY * rotMat;

--format "--DEBUG: x=% y=% z=%\n" endX endY endZ;

-- Max atan always in degrees...yay

-- X is axis down bone, Z is up, but will probably move a lot, so look at one back/sideways = Y

autoTwistX = 0.0;

-- First make sure we don't have a divide by 0 error...

if (endY.z != 0) then

autoTwistX = atan (endY.y / endY.z) +90;

-- Then if we have crossed above the Y=0 line, we will have a 180 flip, so handle that...

if (endY.z > 0) then


autoTwistX -= 180;


autoTwistX = -1*autoTwistX; -- Do this just so things rotate the right way

-- Now add in any manual override the user did using the handCTRL attribute.

autoTwistX *= $'char_handLCTRL'.Attribute_Holder.autoTwistPct / 100.0;

autoTwistX += $'char_handLCTRL'.Attribute_Holder.extraTwist;





-- End of autoTwist script

Last edited by Linus Ericson : 10 October 2003 at 09:03 PM.
  01 January 2006
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 06:34 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.