Vue Python for Beginners
So how do I use a Python Script?
First of all it needs to be on your computer. Save it somewhere on your computer that you can find it again. If it came as an archive (zip files are the most common) you’ll need to uncompress the archive. For the rest of this tutorial I’ll be using my http://www.impworks.co.uk/works/vuepythonscripts/randomwalk.zip script. If you don’t already have it on your computer download it now and unzip it.
It also needs to have been written for the version of Vue you’re using. Some scripts will require that you have the most recent release of Vue so they can work properly. It may say what version of Vue it requires or has been tested with. The script may come with separate instructions or the instructions may be at the top of the Python script. If they are at the top of the script, open it in a text editor (such as Word Pad on a PC) to read them.
For example: at the top of random_walk.py there are some instructions.
#******************************************************
# Add a random walk animation to selected objects
# - random_walk.py
# - Give Selected Objects a simple random
# animation
# - By Mark Caldwell
# - Version 0.1
# - 30th April 2006
#
# How to use in 4 easy steps
#
# 1. Download this file onto your computer
#
# 2. Edit the configuration variables below
#
# 3. Select Objects to be Replace in Vue Infinite
#
# 4. Then run script and wait for it to work
# To run it go to Python -> Run Python Script
# Then locate the file on your computer
#
#******************************************************
We’ll come back to these in a moment in detail, especially step 2.
If the script has instructions that need to be followed before it is run (like step 3 in the random_walk.py script) carry them out now.
To run a script, run Vue and go to the Python Menu. Next select “Run Python script…” . Then find the script on your computer, select it and click Open. It should now run. Some scripts run quickly, some not so quickly depending on how complex they are. If you’ve run the script before, recently, it will appear in the list of five scripts on the Python menu, saving you time finding it.
The Instructions say to Edit the Script. Help!
#----------------------------------------------
# Configuration: Set these to alter end result
#----------------------------------------------
# Frames to generate
start=0 # First frame of animation
stop=101 # Last frame of animation if step divides into
stop add 1 to get a frame on last step
step=10 # Number of frames between key frames
# Starting Velocity of objects
velsxmin=-1 # Starting Minimum Velocity in the x direction
velsxmax=1 # Starting Maximum Velocity in the x direction
velsymin=-1 # Starting Maximum Velocity in the y direction
velsymax=1 # Starting Maximum Velocity in the y direction
velszmin=-1 # Starting Maximum Velocity in the z direction
velszmax=1 # Starting Maximum Velocity in the z direction
# Random Walk accelerations applied at a key frame
accxmin=-20 # Minimum Acceleration the x direction
accxmax=20 # Maximum Acceleration the x direction
accymin=-20 # Minimum Acceleration the y direction
accymax=20 # Maximum Acceleration the y direction
acczmin=-20 # Minimum Acceleration the z direction
acczmax=20 # Maximum Acceleration the z direction
By changing these lines you can change what the script does. Each line has a variable that you can change that will change how the script works when it’s run eg start=0 . This is setting the first frame of the animation. If I wanted to only have it animate from the tenth frame I could change it to start=10 . If I want it to stop at the fiftieth stop=50.
Once you’ve made the changes save the script and try running it.
Hopefully it will run. but if it doesn’t have a look at the Python Console in Vue by going to Python Menu then Python Console. There may be an error message there that tells you where the problem is (you may have put a letter in instead of a number for example). If you don’t understand an error message just go back to the copy and try again.
