[Closed] rotate() returns "call needs function"
Hi,
I have this script where I first want to rotate an object along one axis, and then another axis. For the second rotation I use the rotate() function. I tested this in the listener without any problems, but inside my script it gives me an: “Type error: Call needs function or class, got: 1”. Could anyone explain this error to me, I find it a bit cryptic? I’ve seen several other people asking about this, but I haven’t read anything that helps me out…
Here’s the snippet of code that gives me this error:
in coordsys segment
(
newBranch.rotation = (eulerAngles 0 90 0)
rotate newBranch (eulerAngles 0 0 newAngle)
)
“segment” is another object in the scene that I am using as the coordinate system. “newBranch” is the object I am rotating. Both are simple boxes. “newangle” is an integer with the angle the “newBranch” should be rotating.
I hope someone can give me a hint
Thanks, Rune
I can’t replicate that error message. It works perfectly here. One problem that should be kicking up an error is NewAngle needs to be a float not integer.
The thing is, if I remove the newAngle part and just do this:
in coordsys segment
(
newBranch.rotation = (eulerAngles 0 90 0)
rotate newBranch (eulerAngles 0 0 120)
)
I still get the same error message. Even removing the “in coordsys brackets” will give me the same error.
I am completely in the blank here. I will play around with this today and see if anything removes the error message, or if I can find a workaround of sorts… The thing that bothers me the most is that I don’t understand the error message itself – so I have no clue where to start!
Thanks,
Rune
Could you post your scene file? I still can’t replicate the error message or any error message for that matter. If the two objects are just cubes then there is something wrong somewhere else in your code. Sometimes Max highlights random lines of code when there is an error.
what happens if you run this?
[left]
[left]in coordsys $box01[/left]
[left](
$box02.rotation = (eulerAngles 0 90 0)
rotate $box02 (eulerAngles 0 0 120)
)[/left]
[/left]
Hi!
It’s not really a scene, it’s a rather big script that I’m writing that creates a branching tree. The piece of extract code here is the part that creates child branches (by first rotating them out of the main branch, and then rotating them around the branch).
I never found out what created that error, but I found a workaround by writing a separate function to do that particular rotation:
fn rotateObjectZAxis rotObject angle =
(
rotate rotObject (eulerAngles 0 0 angle)
)
I wish the maxscript manual had a separate section or error codes, I would really like to know what that error meant…
Rune
I have seen that error message before but I’m trying to recreate a scenario and am failing to do so.
I’ll PM you the version of the script that errors out – hope you can find out what it is
Rune
You were trying to define “rotate” as a global variable earlier in your code. So when it tried to run that part of the code it was actually executing:
[left]in coordsys segment[/left]
(
newBranch.rotation = (eulerAngles 0 90 0)
5 newBranch (eulerAngles 0 0 120)
)
[left][/left]
It’s a miracle the code was getting as far as it did. It should have warned you that you were using a variable name that was reserved. And the reason it probably works inside of the function then is that the variable isn’t available within the function and you just kind of lucked out.
So to answer the original question “Call needs function, got: XYZ”
Would occur in:
undeclaredfunction = "XYZ" as string
Undeclaredfuction ()
ERROR: Call needs function, got: “XYZ”
Aahhhh! Thanks a lot!
Weird that I got no warning though. I will update my Ultraedit file, I think it might contain a very old list of reserved names. Thanks for explaining that error message too!
Cheers,
Rune