没有合适的资源?快使用搜索试试~ 我知道了~
Introduction_to_Python.pdf
需积分: 10 2 下载量 34 浏览量
2013-06-06
22:23:59
上传
评论
收藏 915KB PDF 举报
温馨提示
试读
53页
Introduction_to_Python.pdf
资源推荐
资源详情
资源评论
www.chadvernon.com
Introduc ripting
1
tiontoPythonSc
ForMayaArtists
ByChadVernon
TableofContents
Introduction..................................................................................................................................................3
AdditionalResources....................................................................................................................................3
PythonintheComputerGraphicsIndustry..................................................................................................3
WhyshouldyoulearnPython?.................................................................................................................3
SomeProgramsthatsupportPython:......................................................................................................4
WhatisPythonusedfor?..........................................................................................................................4
IntroductiontoPython.................................................................................................................................5
WhatisPython?........................................................................................................................................5
ThePythonInterpreter.............................................................................................................................5
WhatisaPythonScript?...........................................................................................................................5
TheInteractivePrompt.............................................................................................................................6
RunningPythonScriptsFromaComma ndPrompt..................................................................................8
RunningScriptsinMayaandwithinaPythonSession.............................................................................9
PythonModules......................................................................................................................................12
DataTypesandVariables............................................................................................................................13
Variables..................................................................................................................................................13
NumbersandMath.................................................................................................................................14
Strings.....................................................................................................................................................15
StringMethods....................................................................................................................................17
Lists.........................................................................................................................................................18
Tuples......................................................................................................................................................19
Dictionaries.............................................................................................................................................19
BooleansandComparingValues............................................................................................................20
ControllingtheFlowofExecution...............................................................................................................22
Conditionals............................................................................................................................................22
www.chadvernon.com
CodeBlocks.........................................................................................................................................23
WhileLoops.............................................................................................................................................23
ForLoops.................................................................................................................................................24
Functions.....................................................................................................................................................26
FunctionArguments................................................................................................................................27
Scope.......................................................................................................................................................27
LambdaExpressions................................................................................................................................28
ExceptionsandErrorHandling....................................................................................................................30
Files.............................................................................................................................................................31
Modules......................................................................................................................................................32
ModulePackages....................................................................................................................................32
Built‐InandThirdPartyModules............................................................................................................33
ClassesandObjectOrientedProgramming................................................................................................34
QuickNotes.............................................................................................................................................34
Classes.....................................................................................................................................................34
InheritanceandPolymorphism...............................................................................................................35
DocumentingYourCode.............................................................................................................................37
SampleScripts.............................................................................................................................................37
PythonOutsideofMayaConclusion...........................................................................................................38
PythoninMaya...........................................................................................................................................39
TheMayaPythonCommandDocumentation........................................................................................40
SampleScripts.............................................................................................................................................46
CallingMELfromPython.............................................................................................................................52
MayaPythonStandaloneApplications.......................................................................................................52
Conclusion...................................................................................................................................................53
2
www.chadvernon.com
Introduction
Thisworkshopisgearedtowardsstuden tswithlittletonoscripting/programmingexperience.Bythe
endofthisworkshop,youwillhavetheknowledgetowriteandrunPythonscriptsinsideandoutsideof
Maya.YouwillnotlearneverythingaboutPythonfromthisworkshop.Thisworkshopincludesallthe
basicinformationyoushouldknowinordertobeproficientinreading,writing,running,andmodifying
Pythonscripts.ThepurposeofthisworkshopisnottomakeyouexpertPythonscripters,buttogiveyou
asolidfoundationfromwhichinfurtheryourPythonstudies.
AdditionalResources
• LearningPython,3rdEditionbyMarkLutz
• DiveIntoPython:http://www.diveintopython.org/toc/index.html
• Thepython_inside_mayaGoogleemail
list:http://groups.google.com/group/python_inside _maya
• http://www.pythonchallenge.com/
PythonintheComputerGraphicsIndustry
WhyshouldyoulearnPython?
• Blizzard
o SeniorLookDevelopmentTechnicalDirector
StrongtechnicalknowledgeofthePythonandMELprogramminglanguages.
o CinematicsEngineer
SignificantPythonand/orPerlexperience
• Pixar
o TechnicalDirector,Rigging
WritingscriptstofacilitateworkflowimprovementsinPythonorMEL,or
workingwithaprogrammertoenablethemtomakesuchimprovements
effectively.
• Lucasfilm/ILM
o DigitalFXArtist(MidLevel)
Someexperiencewritingscripts(MEL,Python)and/orprogrammingis
necessary.
o AnimationAssistantTechnicalDirector
ExperiencewithMel&Pythonrequired.
o DigitalArtistGroup‐CreatureTD
ExperiencewithC++,mel,python,orotherscriptinglanguagesisdesirable.
o TechnicalAssistant
Strongscriptinglanguage(i.e.Python,Perl)andprogramminglanguage(i.e.
C/C++,Java)isamust.
• ImageMoversDigital
o LookDevelopmentTD
3
Someexperiencewithscripting/programminglanguages(python,MEL,PERL,C,
C++)isaplus.
www.chadvernon.com
o StereoscopicTD
Python‐‐solidintermediate‐to‐advancedskilllevel.
o CharacterTD
Pythonscriptingand/orAPI/programmingexperiencepreferred.
o LightingTD
ThoroughknowledgeofUNIX/Linux,proceduralandobject‐oriented
programminglanguages,shader/plug‐inwritingaswellas
shell/Perl/Mel/Pythonscripting.
• WetaDigital
o WaterTD
ExperiencescriptinginPythonormelpreferred.
o LightingTD
ExperiencescriptinginPythonormelpreferred.
o FXTD
ExperiencescriptinginPythonormelpreferred.
o CreatureTD/SeniorCreatureRigger
Python,Perl,andC++knowledgeapl us.
o FacialModelers
ExperiencewithMudbox,andabilitytoscriptinMELandPythonisanasset
o Modelers
ExperiencewithMudbox,andabilitytoscriptinMELandPythonisanasset.
• Tippett
o CharacterTD
Experiencewithscriptingandprogramming:StrongMayaMELscriptingskills.
Pythonscriptingknowledgepreferred.
o FXAnimator
Experiencewithscriptingandprogramming:StrongMayaMELscriptingskills.
Pythonscriptingknowledgepreferred.
SomeProgramsthatsupportPython:
• Maya
• Modo
• Houdini
• XSI
• Massive
• Blender
• Photoshop(indirectly)
• 3dsmax(indirectly)
WhatisPythonusedfor?
Artistscan
4
• Automaterepetitiveand/ortedioustasks.
• Reducehumanerror.
www.chadvernon.com
• Producemorecreativeiterationsinthefeedbackloop.
Engineerscan
• Createapplicationsandtoolstorunstudiopipelines.
• Customizeexistingapplicationstosupportstudiospecificworkflows.
• Letartistsbeartists.
IntroductiontoPython
WhatisPython?
Pythonisageneralpurposescriptinglanguageusedinmanydifferentindustries.Itisarelativelyeasyto
useandeasytolearnlanguage.Pythonisusedininternetservices,hardwaretesting,game
development,animationproduction,interfacedevelopment,databaseprogramming,andmanyother
domains.
ThePythonInterpreter
HowdoesthecomputerrunaPythonprogram?Howcanyougetthecomputertounderstandthe
Pythoncommandsyouwriteinatextfile?ThePythonInterpreteristhesoftwarepackagethattakes
yourcodeandtranslatesitintoaformthatthecomputercanunderstandinordertoexecutethe
commands.Thistranslatedformiscalledbytecod e.
ThePythonInterpretercanbedownloadedandinstalledforfreefromthePythonwebsite
(http://www.python.org/download/
).Linux,Unix,andMacplatformsusuallyshipwithaPython
Interpreteralreadyinstalled.Windowsuserswillneedtodownloadandinstalltheinterpreterifthey
wanttousePythonoutsideofprogramssuchastheoneslistedabove.Maya8.5andlaterhasaPython
InterpreterbuiltinsoyoucouldlearntousePythoninsidethescripteditorofMaya.
TherearedifferentversionsofthePythonInterpreter.Atthetimeofthiswriting,thelatestversionis
3.0.Maya8.5usesPython2.4.Maya2008usesPython2.5.LinuxandMacuserscouldhaveolder
versionsshippedwiththeirmachinessothey’llneedtoupgradeiftheywant accesstonewerPython
functionality.
Pythonisavailableintwodownloadtypes:installerandsourcecode.Theinstaller(an.msifileor.dmg
file)iswhatmostpeoplewilldownloadtogetPythonontheirmachine.SourcecodeisusedbyLinux
usersandsuperdorks.Pythonisascriptinglanguagethatwascreatedwithanotherprogramming
languageandthesourcecodecontainsthefilesnecessarytobuildandinstallitonLinuxmachines.
Ignorethesourcedownloadandjustgettheinstallerfornow.
WhatisaPythonScript?
5
APythonscriptissimplyabunchofcommandswritteninafilewitha.pyextension.Thistextfile isalso
calledaPythonmodule.This.pyfilecanbewritteninanytexteditorlikeNotePad,WordPad,vi,
emacs,Scite,etc.However,youdonotalwayshavetowriteyourcodeina.pyfile.Forquicktestsand
scripts,youcanruncodedirectlyfromtheMayascripteditororfromtheinteractiveprompt.
剩余52页未读,继续阅读
资源评论
bgbg108555
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功