The first thing we will need to do is to get Python installed! (This is already installed in the labs.)
- To install Python 2.5 (not Python 2.6 or 3.0):
- Download msi file
- Double click the file that you downloaded.
- To install Eclipse Galileo:
- Download zip file
- Unzip the file anywhere on your hard disk - e.g. in C: drive
- To start Eclipse, double click the eclipse.exe file
- To install PyDev
- Start Eclipse
- In the menu, go to Help > Install new software
- Click the Add button
- In the Add Site dialog box, enter:
Name: PyDev
Location: http://pydev.sourceforge.net/updates/ - Then click install...
- To install PyDev Extensions
- Start eclipse
- In the menu, go to Help > Install new software
- Click the Add button
- In the Add Site dialog box, enter:
Name: PyDev
Location: http://www.fabioz.com/pydev/updates - Then click install...
- To tell Eclipse where Python is:
- Start eclipse
- In the menu, go to Window > Preferences
- In the preferences dialog box, navigate to 'Pydev > Interpreter - Python'
- Click the 'New' button
- In the select Interpreter dialog box:
Interpreter Name: Python25
Interpreter Executable: click 'Browse' and navigate to find Python.exe
C:\Python25\python.exe - Click 'OK' and 'OK' again
- To create a new project
- Start eclipse
- In the menu, go to File > New > Pydev Project
- In the dialog box:
Project name: type any name
Use default: tick to use your default workspace
Choose Project: Python
Grammar Version: 2.5
Interpreter: Python25
Create default 'src'...": untick this - it is not needed - Click Next and Finish
- To tell the Python where your project is:
- In the Pydev Package Explorer, find your project folder
- Right click the folder and select 'Properties'
- Click on 'PyDev - PYTHONPATH'
- Click the 'Add source folder' button
- Click 'OK'
- To test that everything is working:
- In the Pydev Package Explorer, find your project folder
- right click the folder and select 'New > Pydev Module'
- In the dialog box:
Source Folder: leave it as it is
Package: leave it as it is, or add a name if you want a sub folder
Name: enter the name of your script, ege. 'test' - Click 'Finish'
- In the script file, type ' print "Hello World" '
- Click the run button (or go to Run > Run)
- Check that you see 'Hello World' in the output console
- To install pywin32 (can only be installed on windows):
- Download the pywin32 file fpr Python25:
http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/pywin32-214.win32-py2.5.exe/download - Run the exe by double clicking the file
- To install py2rhino and py2ecotect:
- Go to the download page for design-automation:
http://code.google.com/p/design-automation/downloads/list - Download the latest version of py2rhino orpy2ecotect
- In Windows explorer, navigate to the Python sitpackages folder
C:\Python25\Lib\site-packages - Delete any older versions by deleting the py2rhino or py2ecotect folders
- Then unzip the py2rhino or py2ecotect into the site-packages folder
- Now go back to eclipse and refresh eclipse as follows:
In the menu, go to Window > Preferences
In the preferences dialog box, go to PyDev > Interpreter - Python
Click the 'Apply' button
- Now test that you can draw something in Rhino
- Start Rhino
- Create a script file in eclipse
- Type:
import py2rhino as p2r
p2r.obj.Line.create( (0,0,0), (5,5,0) )
print "done" - Click the run button (or go to Run > Run)
- Check that you see a line in Rhino and the 'done' is printed to the output console
No comments:
Post a Comment