WARNING: Script error: "name 'scene' is not defined"

User_Peek
Posts: 10
Joined: Tue Apr 12, 2016 12:19 pm

WARNING: Script error: "name 'scene' is not defined"

Post by User_Peek » Tue Apr 12, 2016 12:25 pm

Hee guys,

I've got a script running, but some lines should stop ad a given frame. Now I found this example script in the Realflow 2015 documentation, but I get this error:
WARNING: Script error: "name 'scene' is not defined" at line number 1.

This is the example script:
if ( ( scene.currentFrame >= 10 ) and ( scene.currentFrame <= 20 ) ):
scene.message( "Current frame in range is: " + str( scene.currentFrame ) )


What did I do wrong?

Thanks!

User avatar
tsn
Posts: 283
Joined: Fri Jun 11, 2010 7:22 am

Re: WARNING: Script error: "name 'scene' is not defined"

Post by tsn » Tue Apr 12, 2016 5:45 pm

Hello and welcome.

It seems as if your RF installation isn't complete and the Python part is missing. How do commands like "scene" and "currentFrame" look? Are they displayed in orange or brown in the script editor? If they're printed in plain grey then it's very likely that the necessary files haven't been installed.
Thomas Schlick | Next Limit Technologies

User_Peek
Posts: 10
Joined: Tue Apr 12, 2016 12:19 pm

Re: WARNING: Script error: "name 'scene' is not defined"

Post by User_Peek » Thu Apr 14, 2016 7:55 am

Hello and thanks!

I've used scripts before, and they have all worked correctly. "scene" and "currentFrame" are both displayed in orange.

User avatar
tsn
Posts: 283
Joined: Fri Jun 11, 2010 7:22 am

Re: WARNING: Script error: "name 'scene' is not defined"

Post by tsn » Thu Apr 14, 2016 8:16 am

Sorry for the late reply.

It puzzles me that the problem starts with "scene". If you're on RF2015 (latest version) you can enable the following option - it will give you a more verbose error message. Please let me know what the error message says:

Preferences > Scripts > Redirect Output to Messages Panel

Another thing you can try is to copy the lines below to a batch script editor (F10) and execute it. The output should be "Done...".

if ( ( scene.getCurrentFrame() >= 10 ) and ( scene.getCurrentFrame() <= 20 ) ):
scene.message( "Current frame in range is: " + str( scene.getCurrentFrame() ) )

Did you insert an indent at "scene.message"? It's very unlikely that you forgot, because then you should get a normal syntax error, but who knows. I also recommend retyping the code instead of copying/pasting it. Sometimes this helps as well, but maybe you did that already.
Thomas Schlick | Next Limit Technologies

User_Peek
Posts: 10
Joined: Tue Apr 12, 2016 12:19 pm

Re: WARNING: Script error: "name 'scene' is not defined"

Post by User_Peek » Thu Apr 14, 2016 9:08 am

Oh don't worry, I found it quit fast tho!

This is the output:

>[14/April/2016 09:57:45] - WARNING: Traceback (most recent call last):
>[14/April/2016 09:57:45] - WARNING: File "MasterUsrScript", line 27, in <module>
>[14/April/2016 09:57:45] - WARNING: NameError
>[14/April/2016 09:57:45] - WARNING: :
>[14/April/2016 09:57:45] - WARNING: name 'scene' is not defined
>[14/April/2016 09:57:45] - WARNING: Script error: "name 'scene' is not defined" at line number 27.
>[14/April/2016 09:57:45] - Using 12 thread(s) for this simulation.
>[14/April/2016 09:57:45] - Using opencl-gpu device AMD Radeon HD - FirePro D500 Compute Engine for Hybrido for this simulation
>[14/April/2016 09:57:45] - Using opencl-gpu device AMD Radeon HD - FirePro D500 Compute Engine for Hybrido for this simulation
>[14/April/2016 09:57:45] - WARNING: Traceback (most recent call last):
>[14/April/2016 09:57:45] - WARNING: File "MasterUsrScript", line 27, in <module>
>[14/April/2016 09:57:45] - WARNING: NameError
>[14/April/2016 09:57:45] - WARNING: :
>[14/April/2016 09:57:45] - WARNING: name 'scene' is not defined
>[14/April/2016 09:57:45] - WARNING: Script error: "name 'scene' is not defined" at line number 27.
>[14/April/2016 09:57:45] - WARNING: Traceback (most recent call last):
>[14/April/2016 09:57:45] - WARNING: File "MasterUsrScript", line 27, in <module>
>[14/April/2016 09:57:45] - WARNING: NameError
>[14/April/2016 09:57:45] - WARNING: :
>[14/April/2016 09:57:45] - WARNING: name 'scene' is not defined
>[14/April/2016 09:57:45] - WARNING: Script error: "name 'scene' is not defined" at line number 27.
>[14/April/2016 09:57:46] - WARNING: Traceback (most recent call last):
>[14/April/2016 09:57:46] - WARNING: File "MasterUsrScript", line 27, in <module>
>[14/April/2016 09:57:46] - WARNING: NameError
>[14/April/2016 09:57:46] - WARNING: :
>[14/April/2016 09:57:46] - WARNING: name 'scene' is not defined
>[14/April/2016 09:57:46] - WARNING: Script error: "name 'scene' is not defined" at line number 27.
>[14/April/2016 09:57:46] - WARNING: Traceback (most recent call last):
>[14/April/2016 09:57:46] - WARNING: File "MasterUsrScript", line 27, in <module>
>[14/April/2016 09:57:46] - WARNING: NameError
>[14/April/2016 09:57:46] - WARNING: :
>[14/April/2016 09:57:46] - WARNING: name 'scene' is not defined
>[14/April/2016 09:57:46] - WARNING: Script error: "name 'scene' is not defined" at line number 27.
>[14/April/2016 09:57:46] - WARNING: Traceback (most recent call last):
>[14/April/2016 09:57:46] - WARNING: File "MasterUsrScript", line 27, in <module>
>[14/April/2016 09:57:46] - WARNING: NameError
>[14/April/2016 09:57:46] - WARNING: :
>[14/April/2016 09:57:46] - WARNING: name 'scene' is not defined
>[14/April/2016 09:57:46] - WARNING: Script error: "name 'scene' is not defined" at line number 27.
>[14/April/2016 09:57:46] - WARNING: Traceback (most recent call last):
>[14/April/2016 09:57:46] - WARNING: File "MasterUsrScript", line 27, in <module>
>[14/April/2016 09:57:46] - WARNING: NameError
>[14/April/2016 09:57:46] - WARNING: :
>[14/April/2016 09:57:46] - WARNING: name 'scene' is not defined
>[14/April/2016 09:57:46] - WARNING: Script error: "name 'scene' is not defined" at line number 27.
>[14/April/2016 09:57:46] - WARNING: Traceback (most recent call last):
>[14/April/2016 09:57:46] - WARNING: File "MasterUsrScript", line 27, in <module>
>[14/April/2016 09:57:46] - WARNING: NameError
>[14/April/2016 09:57:46] - WARNING: :
>[14/April/2016 09:57:46] - WARNING: name 'scene' is not defined
>[14/April/2016 09:57:46] - WARNING: Script error: "name 'scene' is not defined" at line number 27.
>[14/April/2016 09:57:46] - WARNING: Traceback (most recent call last):
>[14/April/2016 09:57:46] - WARNING: File "MasterUsrScript", line 27, in <module>
>[14/April/2016 09:57:46] - WARNING: NameError
>[14/April/2016 09:57:46] - WARNING: :
>[14/April/2016 09:57:46] - WARNING: name 'scene' is not defined
>[14/April/2016 09:57:46] - WARNING: Script error: "name 'scene' is not defined" at line number 27.


The output from the batch file was indeed "Done...". So that does mean it's installed correctly, doesn't it?

And I had inserted an indent at "scene.message" and I've also retyped it.

User avatar
tsn
Posts: 283
Joined: Fri Jun 11, 2010 7:22 am

Re: WARNING: Script error: "name 'scene' is not defined"

Post by tsn » Thu Apr 14, 2016 9:45 am

The output from the batch file was indeed "Done...". So that does mean it's installed correctly, doesn't it?
Yes, I'd say so and the error must be somewhere else, but that's difficult to find out without taking a look at the entire script. Is it possible to send me the script for debugging? If you don't want to share it here you can PM it to me.
Thomas Schlick | Next Limit Technologies

User_Peek
Posts: 10
Joined: Tue Apr 12, 2016 12:19 pm

Re: WARNING: Script error: "name 'scene' is not defined"

Post by User_Peek » Thu Apr 14, 2016 9:57 am

Okay thanks! I've send you a pm with the code

User_Peek
Posts: 10
Joined: Tue Apr 12, 2016 12:19 pm

Re: WARNING: Script error: "name 'scene' is not defined"

Post by User_Peek » Fri Apr 15, 2016 8:08 am

In the mean time, anyone else any suggestions?

User avatar
tsn
Posts: 283
Joined: Fri Jun 11, 2010 7:22 am

Re: WARNING: Script error: "name 'scene' is not defined"

Post by tsn » Fri Apr 15, 2016 8:41 am

I've inserted the missing indents to the script you sent me yesterday and tested it. You certainly don't want to hear that, but I didn't have any problems. I don't which type of license you have (demo, le, standard), but I've attached a complete scene with the script included. If you have the demo version you can load the included script (.rfs) and test it in your own scene. You should get a message between frame 10 and 20.
user_peek.zip
Sorry, but I really can't trace the error here.

Cheers,
Thomas
You do not have the required permissions to view the files attached to this post.
Thomas Schlick | Next Limit Technologies

User_Peek
Posts: 10
Joined: Tue Apr 12, 2016 12:19 pm

Re: WARNING: Script error: "name 'scene' is not defined"

Post by User_Peek » Fri Apr 15, 2016 9:11 am

Okay, I've got no idea why, but it's working now. I guess it were the missing indents. I imported the script you send me and it's working. So thanks anyway! I'm a happy man, haha.

Cheers!
Last edited by User_Peek on Fri Apr 15, 2016 9:39 am, edited 1 time in total.

Post Reply