没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Python
101
for Rhinoceros 5
© 2011 All Rights Reserved
Revision 3
Introduction
You’ve just opened the rst edition of the Rhino Python primer. This booklet was originally written by David
Rutten of Robert McNeel & Associates for Rhino 4 and VBscript and has now been translated to encompass Python
for Rhino 5. As always, this primer is intended to teach programming to absolute beginners, people who have
tinkered with programming a bit or expert programmers looking for a quick introduction to the methods in
Rhino. Rhinoscript (VBscript) has been supported for many years, with a large user group and extensive support
material. As well as giving a basic introduction, this primer looks to easily transition those familiar with VBscript
into the world of Rhino Python. For this reason, David Rutten's original primer has been used extensively as the
underlying framework for this Python Primer. Python offers exciting new potentials for programming in Rhino
with Object-Oriented functionality, simple syntax, access to the .NET framework and a vast number of user-built
libraries to extend Rhino's functionality. The same powerful methods that were previously in VBscript are still
available, as well as a ton of other exciting methods and features available natively with Python.
Similar to the previous primers, we have the advantage of using geometric and visual examples to help teach
programming. In many traditional scenarios, programming is taught with non-visual examples and difcult to
understand engineering problems. For this reason, as well as Python's easy-to-read syntax, we should hopefully
be able to bring everyone to understand and write simple programs to help automate and design within Rhino.
Programming offers users the powerful ability to automate tasks, make decisions, perform powerful calculations
and geometric manipulations, thus, essentially acting as a designer's side kick. This can allow thousands of
computations to occur based on dynamic conditions, something that would take a human far too long to process.
As a tool for iteration, generation, analysis and design evolution, programming is limitless! Programming also
offers a new language to communicate with the world because almost every discipline, from the Sciences,
Engineering to Art, utilize code as a progressive new medium - and this primer should hopefully give you an easy
introduction into this powerful language for communicating with the world. (With that example, it should be
noted that programming may be looked at as any other human language in the sense that it truly takes many
hours of practice to become uent. So don't get discouraged if you aren't an expert in one day!)
I hope we have convinced you of the powerful and exciting potential for this new opportunity of Python in Rhino.
Without further ado, lets dive in!
Good luck!
Skylar Tibbits
SJET
www.sjet.us
www.scriptedbypurpose.net
Arthur van der Harten
Kirkegaard Associates
www.perspectivesketch.com
www.kirkegaard.com
Steve Baer
Robert McNeel & Associates
www.rhino3d.com
www.python.rhino3d.com
A special thanks to David Rutten for the inspiration and invaluable work, pioneering the original Rhinoscript101
Primer. Also many thanks to Bob McNeel and everyone at Robert McNeel & Associates for their generous support!
Where to nd help...
Forums:
The RhinoPython community is very active and offers a wonderful resource for posting questions/answers and
nding help on just about anything!:
http://python.rhino3d.com/forums/
General References for Python:
Python's main website offers a plethora of information about the syntax, building-in functionality, libraries etc!
This is the main resource for anything Python!
http://docs.python.org/
The Python Documentation also has a great introduction into the basics of Python:
http://docs.python.org/tutorial/introduction.html
http://docs.python.org/tutorial/
A very useful Python style guide:
http://www.python.org/dev/peps/pep-0008/
Another very thorough resource for Python is from MIT, called "How to Think Like a Computer Scientist":
http://www.greenteapress.com/thinkpython/thinkCSpy/thinkCSpy.pdf
Common Exceptions/Errors:
For a list of common errors, exceptions and pitfalls that you are likely to run into when coding see:
http://docs.python.org/release/3.1.3/library/exceptions.html#bltin-exceptions
http://secant.cs.purdue.edu/_media/proghints.pdf
Syntax & Programming Reminders:
-Python is Case Sensitive ("A" and "a" are NOT the same thing!)
-Python is Indent Sensitive (Use indentation to delineate the scope of loops, conditionals, functions and classes)
Remember an extra space or the absence of a space can make a world of a difference!
-You do NOT need to declare variables or variables types! Just simply use them (x=3)!
-The " # " sign is used for comments, the computer will skip over them.
-Print and Return are NOT the same thing - print writes something to the screen, return actually passes a value!
-Remember Variable Scope - where you dene a variable is important! Variables dened within functions &
classes can only be used within those functions/classes unless passed as input or through the return statement!
-Develop code incrementally, testing, debugging and printing as you nish smaller sections. Writing hundreds of
lines and hitting run will most likely not work and will make it far more difcult to spot errors!
***If this makes no sense to you yet - no fear! Keep reading (and come back to it later)!...
Table of Contents
Introduction
Where to nd help
Table of Contents
1
What's it all about?
2
1.1 Macros 2
1.2 Scripts 3
1.3 Running Scripts 3
2
Python Essentials
4
2.1 Language origin 4
2.2 Flow control 5
2.3 Variable data 5
2.3.1 Integers and Doubles 6
2.3.2 Booleans 7
2.3.3 Strings 7
2.3.4 None variable 8
2.3.5 Using variables 9
3
Script anatomy
11
3.1 Programming in Rhino 11
3.2 The bones 12
3.3 The guts 13
3.4 The skin 13
3.5 The Debugger 14
4
Operators and functions
15
4.1 What on earth are they and why should I care? 15
4.2 Careful… 16
4.3 Logical operators 17
4.4 Functions and Procedures 19
4.4.1 A simple function example 20
4.4.2 Advanced function syntax 22
4.5 Mutability 24
5
Conditional execution
25
5.1 What if? 25
5.2 Looping 27
5.3 Conditional loops 27
5.4 Incremental loops 30
剩余119页未读,继续阅读
资源评论
- hongwudaan2017-02-08谢谢楼主分享,英语一般,得仔细看啦。
unfinal222
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功