您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > Dynamo_language_guide-中文版
DynamoLanguageManual基于官方手册翻译,如有错误欢迎指出。翻译:白马、心隐草、未知数、看山是水(以上排名不分先后)Dynamo设计综合:318783072(QQ群)1.语言基础知识2.几何基础知识3.基本几何体4.向量(Vector)数学5.范围(Range)表达式6.集合7.函数8.数学9.曲线:插入点曲线和控制点曲线10.移动,旋转,和其他变形11.条件判断和布尔逻辑运算12.循环13.ReplicationGuides14.集合层级和锯齿状集合15.曲面:插入点,控制点,放样,旋转成型16.几何体参数化17.相交和剪切18.几何体布尔运算A-1.附件1:PythonPointGeneratorsContentsProgramminglanguagesarecreatedtoexpressideas,usuallyinvolvinglogicandcalculation.Inadditiontotheseobjectives,theDynamotextuallanguage(formerlyDesignScript)hasbeencreatedtoexpressdesignintentions.Itisgenerallyrecognizedthatcomputationaldesigningisexploratory,andDynamotriestosupportthis:wehopeyoufindthelanguageflexibleandfastenoughtotakeadesignfromconcept,throughdesigniterations,toyourfinalform.Thismanualisstructuredtogiveauserwithnoknowledgeofeitherprogrammingorarchitecturalgeometryfullexposuretoavarietyoftopicsinthesetwointersectingdisciplines.Individualswithmoreexperiencedbackgroundsshouldjumptotheindividualsectionswhicharerelevanttotheirinterestsandproblemdomain.Eachsectionisself-contained,anddoesn’trequireanyknowledgebesidestheinformationpresentedinpriorsections.TextblocksinsetintheConsolasfontshouldbepastedintoaCodeBlocknode.TheoutputoftheCodeBlockshouldbeconnectedintoaWatchnodetoseetheintendedresult.Imagesareincludedintheleftmarginillustratingthecorrectoutputofyourprogram.Introduction编程语言的产生是为了表达思想,通常包括逻辑和计算。除了这些目标,Dynamo文本语言(原名DesignScript)已经建立表达设计意图。通常认为,计算式设计是探索性的,Dynamo试图支持如下:我们希望你们找到语言的灵活性、从概念设计、通过设计迭代快速完成你的最终形式。本手册的结构是给没有编程或建筑几何知识的用户充分展示这两个交叉学科的各种话题。经验更丰富的用户应该跳到他们感兴趣及问题领域的相关章节。每个章节均是独立的,除了在先前章节提供的信息外不需要其他知识。嵌入在Consolas字体里的文本块应可以被粘贴到代码块节点内。代码块的输出应被链接到一个Watch节点,以便看到预期的结果。左边的图块显示程序的正确输出。说明ThisdocumentdiscussestheDynamotextualprogramminglanguage,usedinsideoftheDynamoeditor(sometimesreferredtoas“DynamoSandbox”).TocreateanewDynamoscript,opentheDynamoeditor,andselectthe“New”buttoninthe“FILES”group:ThiswillopenablankDynamograph.TowriteaDynamotextscript,doubleclickanywhereinthecanvas.Thiswillbringupa“CodeBlock”node.Inordertoeasilyseetheresultsofourscripts,attacha“Watch”nodetotheoutputofyourCodeBlocknode,asshownhere:Everyscriptisaseriesofwrittencommands.Someofthesecommandscreategeometry;otherssolvemathematicalproblems,writetextfiles,orgeneratetextstrings.Asimple,onelineprogramwhichgeneratesthequote“Lessismore.”lookslikethis:TheWatchnodeontheleftshowstheoutputofthescript.Lessismore.;1:LanguageBasics本文探讨Dynamo文本编程语言,使用内部的Dynamo编辑器(有时被称为“Dynamo沙箱”)。打开Dynamo编辑器,在“FILES”菜单选择“New”按钮,新建一个Dynamo脚本。这将打开一个空白的Dynamo图档。双击画布上的任意地方来编写Dynamo文本脚本。这将会打开“代码块”节点。为了更方便看到脚本输出结果,在代码块节点输出端附加一个Watch节点,如下所示:每个脚本都是一系列的书面命令。其中一些命令创建几何体;另外一些解决数学问题、写入文本文件、或者生成文本字符串。一个简单例子,一行程序生成“Lessismore”的引用,看起来像这样:左侧的Watch节点显示脚本输出。语言基础ThecommandgeneratesanewStringobject.StringsinDynamoaredesignatedbytwoquotationmarks(),andtheenclosedcharacters,includingspaces,arepassedoutofthenode.CodeBlocknodesarenotlimitedtogeneratingStrings.ACodeBlocknodetogeneratethenumber5420lookslikethis:EverycommandinDynamoisterminatedbyasemicolon.Ifyoudonotincludeone,theEditorwilladdoneforyou.Alsonotethatthenumberandcombinationofspaces,tabs,andcarriagereturns,calledwhitespace,betweentheelementsofacommanddonotmatter.Thisprogramproducestheexactsameoutputasthefirstprogram:Naturally,theuseofwhitespaceshouldbeusedtohelpimprovethereadabilityofyourcode,bothforyourselfandfuturereaders.Commentsareanothertooltohelpimprovethereadabilityofyourcode.InDynamo,asinglelineofcodeis“commented”withtwoforwardslashes,//.Thismakesthenodeignoreeverythingwrittenaftertheslashes,uptoacarriagereturn(theendoftheline).Commentslongerthanonelinebeginwithaforwardslashasterisk,/*,andendwithanasteriskforwardslash,*/.5420;LessIsMore.;该命令新建一个字符串对象。Dynamo中的字符串是由两个引号()中之间的字符组成,字符包括空格。代码块不限于生成字符串,一个代码块节点生成数值5420看起来像这样:Dynamo中的命令以分号结束。如果不含,编辑器将会自动增加。另外注意的是,数字和字符组合(空格、制表符和回车等空白字符),一个命令之间的元素无关紧要。这个程序的输出与第一个程序一样。当然,空白字符应用于帮助提高代码的可读性,不管是对自己还是将来的读者。注释是另一种提升代码可读性的工具。在Dynamo中,单行注释代码以双斜杆“//”开头。这将使得节点忽视斜杆后的所有信息,直到回车符(该行的结尾)。多行注释是以斜杆星号(/*)开头,以星号斜杆(*/)结尾。SofartheCodeBlockargumentshavebeen‘literal’values,eitheratextstringoranumber.Howeveritisoftenmoreusefulforfunctionargumentstobestoredindatacontainerscalledvariables,whichbothmakecodemorereadable,andeliminateredundantcommandsinyourcode.Thenamesofvariablesareuptoindividualprogrammerstodecide,thougheachvariablenamemustbeunique,startwithaloweroruppercaseletter,andcontainonlyletters,numbers,orunderscores,_.Spacesarenotallowedinvariablenames.Variablenamesshould,thougharenotrequired,todescribethedatatheycontain.Forinstance,avariabletokeeptrackoftherotationofanobjectcouldbecalledrotation.Todescribedatawithmultiplewords,programmerstypicallyusetwocommonconventions:separatethewordsbycapitalletters,calledcamelCase(thesuccessivecapitallettersmimicthehumpsofacamel),ortoseparateindividualwordswithunderscores.Forinstance,avariabletodescribetherotationofasmalldiskmightbenamedsmallDiskRotationorsmall_disk_rotation,dependingontheprogrammer’sstylisticpreference.Tocreateavariable,writeitsnametotheleftofanequalsign,followedbythevalueyouwanttoassigntoit.Forinstance:Besidesmakingread
本文标题:Dynamo_language_guide-中文版
链接地址:https://www.777doc.com/doc-4327788 .html