PDA

View Full Version : Newbie problem with procedure


arjan_meerten
02-13-2004, 04:11 PM
Hi there

I have a problem when making a procedure of a smal script of mine and put it on an button.
The script is more like an action. The action makes a copy of my selected character, unlockes the channel attributes, and adds some attributes with information I want to use when I'm using these copies as blendshapes. First I select a bone and then I select the skin.
The script runs fine, but when I make a procedure from it, maya gives this error.

Error: Invalid call to "floor". Check number and types of arguments expected by the procedure.

This is the script:

global proc scriptA () {

$selec = `ls -sl`;
$gradenX = getAttr ($selec[0] + ".rotateX");
$gradenY = getAttr ($selec[0] + ".rotateY");
$gradenZ = getAttr ($selec[0] + ".rotateZ");
$gradenXflr = floor($gradenX);
$gradenXabs = abs($gradenXflr);
$gradenYflr = floor($gradenY);
$gradenYabs = abs($gradenYflr);
$gradenZflr = floor($gradenZ);
$gradenZabs = abs($gradenZflr);
gotoBindPose;
$newn = "lijf" + "_" + $selec[0] + "_" + "X" + $gradenXabs + "_" + "Y" + $gradenYabs + "_" + "Z" + $gradenZabs;
duplicate -n $newn $selec[1];
parent -w $newn;
setAttr -l false ($newn + ".translateX");
setAttr -l false ($newn + ".translateY");
setAttr -l false ($newn + ".translateZ");
setAttr -l false ($newn + ".rotateX");
setAttr -l false ($newn + ".rotateY");
setAttr -l false ($newn + ".rotateZ");
setAttr -l false ($newn + ".scaleX");
setAttr -l false ($newn + ".scaleY");
setAttr -l false ($newn + ".scaleZ");
setAttr ($newn + ".translateX") 15;

addAttr -ln blendinfo_rotX -at double;
setAttr -e -keyable true ($newn + ".blendinfo_rotX");
setAttr ($newn + ".blendinfo_rotX") $gradenX;

addAttr -ln blendinfo_rotY -at double;
setAttr -e -keyable true ($newn + ".blendinfo_rotY");
setAttr ($newn + ".blendinfo_rotY") $gradenY;

addAttr -ln blendinfo_rotZ -at double;
setAttr -e -keyable true ($newn + ".blendinfo_rotZ");
setAttr ($newn + ".blendinfo_rotZ") $gradenZ;

addAttr -ln jointname -dt "string";
setAttr ($newn + ".jointname") -type "string" $selec[0];

layerEditorAddObjects blends;

}

I hope you can help me with this problem

thanx in advance

Jhavna
02-13-2004, 04:44 PM
you need to cast what you pass into fllor as a float.

i.e. rewrite

$gradenX = getAttr ($selec[0] + ".rotateX");

to

float $gradenX = getAttr ($selec[0] + ".rotateX");

as well as all the others

Nicool
02-13-2004, 04:56 PM
You must declare data type of your variables.

int 1, 15, 148
float 1.25, 0.2, 12.056
string "Mother", "Dadi"

Example :

int rand(0, 2); returns 0 or 1 or 2 (often 1)
float rand(0,2) returns 1.42 or 1.0365 or 0.956 ...

arjan_meerten
02-13-2004, 05:13 PM
Thanks a lot for youre fast replies

It is working now.
Until now I only made small scripts and I never had problems with not defining the proper variable type. So I guess when you make a procedure I have to make sure al the variables are difined proper.

thanx again for youre repies

CGTalk Moderation
01-17-2006, 10:00 AM
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.