{"id":899,"date":"2016-05-06T10:00:00","date_gmt":"2016-05-06T08:00:00","guid":{"rendered":"https:\/\/blogs.autodesk.com\/villagebim\/2016\/05\/exemple-dynamo-mon-premier-code-python.html"},"modified":"2021-02-09T21:58:45","modified_gmt":"2021-02-09T19:58:45","slug":"exemple-dynamo-mon-premier-code-python","status":"publish","type":"post","link":"https:\/\/blogs.autodesk.com\/villagebim\/2016\/05\/exemple-dynamo-mon-premier-code-python.html","title":{"rendered":"Exemple Dynamo : mon premier code Python"},"content":{"rendered":"<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b8d1b0939b970c-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"313\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e9760b837.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa745970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"205\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e9778cd9b.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Voil\u00e0, je vous avais promis de m\u2019investir dans le script Python, c\u2019est en partie chose faite !<\/p>\n<p style=\"text-align: justify\">Attention, je commence donc c&#039;est un exemple qui d\u00e9bute tout doucement.<\/p>\n<p style=\"text-align: justify\">Voici l\u2019exemple: il s\u2019agit d\u2019un Moucharabieh soit un motif r\u00e9p\u00e9titif. Il va falloir recopier ce motif suivant une boucle de type \u201c<em>For<\/em>\u201d, d\u2019o\u00f9 l\u2019utilisation du code python.<\/p>\n<p style=\"text-align: justify\">Nous allons d\u00e9couper l\u2019exemple en trois parties :<\/p>\n<blockquote>\n<p>&#8211; Cr\u00e9ation du motif r\u00e9p\u00e9titif dans une famille de type \u201cMod\u00e8le g\u00e9n\u00e9rique\u201d,<\/p>\n<p>&#8211; R\u00e9alisation du script visuel,<\/p>\n<p>&#8211; Ajout&#160;du&#160;code python&#160;au script.<\/p>\n<\/blockquote>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\"><strong><u>1- Cr\u00e9ation du motif r\u00e9p\u00e9titif :<\/u><\/strong><\/p>\n<p style=\"text-align: justify\">L\u00e0, c\u2019est la partie artistique de l\u2019exemple. A partir d\u2019une famille g\u00e9n\u00e9rique, j\u2019ai cr\u00e9\u00e9 le motif ci-dessous. Rien de compliqu\u00e9, la cr\u00e9ation de ce volume commence par plusieurs surfaces que l\u2019on va extruder \u00e0 l\u2019aide de l\u2019option \u201c<em>Cr\u00e9er une forme<\/em>\u201d soit sous forme \u201c<em>Solide<\/em>\u201d soit sous forme \u201c<em>Forme vide<\/em>\u201d.<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b8d1b093b2970c-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"250\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e9791f385.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b7c8262f7e970b-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"167\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e97aa3549.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"117\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Nota : J\u2019ai rajout\u00e9 un param\u00e8tre de mat\u00e9riau \u00e0 la famille pour des questions&#160;d\u2019esth\u00e9tique.<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\"><strong><u>2- R\u00e9alisation du script visuel :<\/u><\/strong><\/p>\n<p style=\"text-align: justify\">Le script visuel Dynamo est assez simple \u00e0 r\u00e9aliser car il s\u2019agit de placer la famille g\u00e9n\u00e9rique \u00e0 de multiples points r\u00e9p\u00e9titifs.<\/p>\n<p style=\"text-align: justify\">Nous allons utiliser un n\u0153ud \u201c<em>Point<\/em>.<em>ByCoordinates<\/em>\u201d. En amont de ce n\u0153ud, nous allons cr\u00e9er un codeblock pour g\u00e9n\u00e9rer une liste de points dans le direction Y par exemple.<\/p>\n<p style=\"text-align: justify\">Enfin, nous allons introduire deux variables :<\/p>\n<blockquote>\n<p>&#8211; La valeur de l\u2019espacement horizontal (d\u00e9pend du motif),<\/p>\n<p>&#8211; Le nombre de n\u0153uds<\/p>\n<p>&#160;<\/p>\n<\/blockquote>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa75f970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"137\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e97c02012.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Explication du codeblock: \u201c<em>0..Esp*Nb..#Nb+1<\/em>\u201d : je g\u00e9n\u00e8re une liste de points donc le d\u00e9part commence \u00e0&#160; z\u00e9ro et finit \u00e0 la valeur du produit \u201cEspacement\u201d et du \u201cNombre\u201d. Enfin, l\u2019espacement entre les points est d\u00e9fini par le \u201cNombre +1\u201d soit ((Espacement*Nombre)\/(Nombre). Le \u201c+1\u201d, c\u2019est l\u2019histoire qu\u2019il y a toujours un&#160;piquet de plus que d\u2019espacement.<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa76b970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"206\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e97d5ede1.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Enfin pour placer le mod\u00e8le g\u00e9n\u00e9rique \u00e0 ces points, nous allons utiliser le n\u0153ud \u201c <em>FamilyInstance.ByPoint<\/em>\u201d, soit le script suivant :<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b7c8262f97970b-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"137\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e97e8ee84.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\"><u>R\u00e9sultat dans Revit :<\/u><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa789970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"250\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e97f9f215.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">A cette \u00e9tape, on pourrait r\u00e9aliser la copie verticale via&#160;ces manipulations :<\/p>\n<blockquote>\n<p>&#8211; relier en Z, notre codeblock (ou un autre codebock avec diff\u00e9rentes valeurs),<\/p>\n<p>&#8211; appliquer une combinaison de type \u201cproduit vectoriel\u201d (recherche de toutes les solutions).<\/p>\n<p>&#160;<\/p>\n<\/blockquote>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa792970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"178\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e9824cacf.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\"><u>R\u00e9sultat dans Revit :<\/u><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa7a2970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"250\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e983b05d2.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Mais nous n\u2019allons par faire&#160;ces op\u00e9rations pour justement r\u00e9aliser un code python. Donc le script que vous devez avoir \u00e0 cette \u00e9tape est :<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b8d1b09409970c-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"137\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e98506613.png\" style=\"padding-top: 0px;padding-left: 0px;margin: 0px auto;padding-right: 0px;border-width: 0px;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\"><strong><u>3- Ajout du code python au script &#160;:<\/u><\/strong><\/p>\n<p style=\"text-align: justify\">Nous allons introduire un code python entre la g\u00e9n\u00e9ration des points et l\u2019affectation \u00e0 la famille.<\/p>\n<p style=\"text-align: justify\">Nous allons cr\u00e9er une autre variable pour connaitre le nombre de points \u00e0 copier verticalement.<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa7ba970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"302\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e98668d9f.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"304\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Pour cr\u00e9er un code python :<\/p>\n<blockquote>\n<p>&#8211; clic droit dans l\u2019interface graphique et faire la recherche du mot cl\u00e9 \u201cpython\u201d,<\/p>\n<p>&#8211; s\u00e9lectionner \u201c<em>Python script<\/em>\u201d,<\/p>\n<p>&#8211; cliquer deux fois sur le symbole \u201c+\u201d pour ajouter deux entr\u00e9es,<\/p>\n<p>&#160;<\/p>\n<\/blockquote>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa7c7970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"201\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e987a40cc.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<blockquote>\n<p>&#160;<\/p>\n<p>&#8211; enfin nous allons connecter chaque entr\u00e9e du n\u0153ud \u201c<em>Python Script<\/em>\u201d :<\/p>\n<p>&#160;&#160;&#160;&#160;&#160; &#8211; Entr\u00e9e 1 (IN[1]) : la liste de points,<\/p>\n<p>&#160;&#160;&#160;&#160;&#160; &#8211; Entr\u00e9e 2 (IN[2]) : le nombre de copies,<\/p>\n<p>&#160;&#160;&#160;&#160;&#160; &#8211; Entr\u00e9e 3 (IN[3]) : le nombre de points,<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b7c8262fd4970b-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"148\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e98925f33.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<\/blockquote>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Nous allons ouvrir le n\u0153ud \u201c<em>Python Script<\/em>\u201d en effectuant un clic droit sur le n\u0153ud et en choisissant&#160; l\u2019option \u201c<em>Edit<\/em>\u2026\u201d<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa7e8970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"387\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e98a92914.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"304\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Apparait l\u2019\u00e9diteur python avec une structure scripturale pr\u00e9-remplie.&#160;<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b7c8262fef970b-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"203\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e98c15dbd.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Le langage python est un langage orient\u00e9 objet comme d\u2019autres langages contemporains comme Java, C++, C#, Visual Basic\u2026Il est compos\u00e9 d\u2019objets de classes, de m\u00e9thodes et de fonctions.<\/p>\n<p style=\"text-align: justify\">Attention : lorsque l\u2019on d\u00e9veloppe, il faut respecter dans les d\u00e9clarations quelques r\u00e8gles:<\/p>\n<blockquote>\n<p>&#8211; la syntaxe (\u201c:\u201d, \u201c;\u201d,\u2026),<\/p>\n<p>&#8211; les majuscules,<\/p>\n<p>&#8211; les retraits (surtout en langage python),<\/p>\n<\/blockquote>\n<p style=\"text-align: justify\">Nous allons commencer par d\u00e9clarer des variables pour r\u00e9cup\u00e9rer les entr\u00e9es du bloc python soit :<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b7c8262ff4970b-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"302\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e98db8038.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Par exemple, je dis que la variable \u201c<em>ListNoeuds<\/em>\u201d r\u00e9cup\u00e8re la valeur issue de entr\u00e9e 1 (soit IN[1]).<\/p>\n<p style=\"text-align: justify\">Nota : je vous conseille de commenter votre code. Cela est possible en rajoutant un \u201c#\u201d en d\u00e9but de ligne.<\/p>\n<p style=\"text-align: justify\">Le but de notre code est de retourner une liste de point, donc nous allons d\u00e9clarer une variable de type \u201cliste\u201d soit la variable \u201c<em>NouveauPoints<\/em>\u201d et retourner celle-ci&#160; en r\u00e9sultat de code pyton (\u201c<em>OUT = NouveauPoints<\/em>\u201d).<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa80a970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"304\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e990b1a66.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Nous allons ajouter une derni\u00e8re variable \u201c<em>DecalageV<\/em>\u201d et lui assigner la valeur de d\u00e9calage vertical de 0,2087 (valeur variant suivant la&#160;hauteur de votre motif -&#160;<strong>attention aux unit\u00e9s<\/strong>).<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b7c8263013970b-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"342\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e9924e856.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Derni\u00e8re op\u00e9ration, nous allons r\u00e9aliser deux boucles imbriqu\u00e9es de type \u201cFor\u201d.<\/p>\n<p style=\"text-align: justify\">Voici le syntaxe :<\/p>\n<p style=\"text-align: justify\"><strong>for j in range (0,NombreDeCopie): <br \/>for i in range(0, NombreDeNoeuds+1): <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; D = ListNoeuds[i]; <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; E = Geometry.Translate(D,0,0,DecalageV*j); <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; NouveauxPoints.append(E);<\/strong><\/p>\n<p style=\"text-align: justify\"><u>Explications :<\/u><\/p>\n<p style=\"text-align: justify\">La premi\u00e8re boucle avec l\u2019indice \u201cj\u201d permet de faire la copie verticale jusqu\u2019au nombre de copies sp\u00e9cifi\u00e9 (\u201c<em>NombreDeCopie<\/em>\u201d).<\/p>\n<p style=\"text-align: justify\">La deuxi\u00e8me boucle va permettre de lire la liste de n\u0153uds (soit de 0 \u00e0 \u201c<em>NombreDeNoeuds+1<\/em>\u201d).<\/p>\n<p style=\"text-align: justify\">La variable \u201cD\u201d vient r\u00e9cup\u00e9rer la liste de n\u0153uds \u00e0 l\u2019indice i (soit lire la liste de n\u0153uds qui pr\u00e9c\u00e8de la copie).<\/p>\n<p style=\"text-align: justify\">La variable \u201cE\u201d cr\u00e9e la translation de \u201cD\u201d (la liste de n\u0153uds) avec la commande de Dynamo script \u201c<em>Geometry.Translate<\/em>\u201d des valeurs :<\/p>\n<blockquote>\n<p>&#8211; en X de z\u00e9ro,<\/p>\n<p>&#8211; en Y de z\u00e9ro,<\/p>\n<p>&#8211; en Z de la valeur de la variable \u201cDecalageV\u201d multipli\u00e9 de la valeur la premi\u00e8re boucle (j=0, 1, 2\u2026.)<\/p>\n<\/blockquote>\n<p style=\"text-align: justify\">Enfin, les valeurs collectionn\u00e9es de la variable \u201cE\u201d sont enregistr\u00e9es dans la variable de type liste \u201c<em>NouveauPoints<\/em>\u201d au moyen de la m\u00e9thode &#039;\u201d<em>append<\/em>\u201d.<\/p>\n<p style=\"text-align: justify\">Attention : observez les retraits de ligne, cela est tr\u00e8s important dans l\u2019association des r\u00e9sultats dans les boucles.<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b8d1b09468970c-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"355\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e993e5ec7.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Cliquer sur le bouton \u201c<em>Accepter les modifications<\/em>\u201d et si tout ce passe bien, le n\u0153ud \u201c<em>Python Script<\/em>\u201d doit avoir une couleur grise. Dans le cas contraire, un message de couleur jaune affiche le type de probl\u00e8me.<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01b7c826302f970b-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"235\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e99582b98.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Lorsque vous r\u00e9alisez un code python, n\u2019attendez pas d\u2019appliquer les modifications lorsque vous avez entr\u00e9 tous le code car il est difficile de trouver les multiples erreurs . Je vous conseille d\u2019avancer petit \u00e0 petit en appliquant les modifications apr\u00e8s avoir rentr\u00e9 quelques lignes.<\/p>\n<p style=\"text-align: justify\"><u>R\u00e9sultat apr\u00e8s avoir liaisonn\u00e9 tous les n\u0153uds:<\/u><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa860970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"160\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e9972fe09.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\"><u>R\u00e9sultat dans Revit :<\/u><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p><a href=\"http:\/\/villagebim.typepad.com\/.a\/6a015391e15a28970b01bb08caa870970d-pi\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" height=\"250\" src=\"https:\/\/blogs.autodesk.com\/villagebim\/wp-content\/uploads\/sites\/154\/2021\/02\/img_6022e9990f5fb.png\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px;margin-left: auto;margin-right: auto;background-image: none\" title=\"image\" width=\"454\" \/><\/a><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Dans le cas de d\u00e9veloppement de code python plus important, je vous conseille d\u2019utiliser un \u00e9diteur de texte python qui permet de corriger automatiquement certaines erreurs et qui poss\u00e8de un debuggeur int\u00e9gr\u00e9.<\/p>\n<p style=\"text-align: justify\">A ce sujet, pour ceux qui d\u00e9veloppent d\u00e9j\u00e0, quel \u00e9diteur de texte python utilisez-vous?<\/p>\n<p style=\"text-align: justify\">Ca sera peut-\u00eatre le&#160;sujet d\u2019un autre article Village BIM.<\/p>\n<p style=\"text-align: justify\">La vid\u00e9o ci-dessous,&#160;vous fait un r\u00e9sum\u00e9 des principales \u00e9tapes:&#160;<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: center\">&#160;<\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n<p style=\"text-align: justify\">Enfin&#160;voici les fichiers :<\/p>\n<p style=\"text-align: justify\"><span class=\"asset  asset-generic at-xid-6a015391e15a28970b01bb08caaefb970d img-responsive\"><a href=\"http:\/\/villagebim.typepad.com\/files\/mouchevillagebim.rvt\">T\u00e9l\u00e9chargement Fichier Revit<\/a><\/span><\/p>\n<p style=\"text-align: justify\"><span class=\"asset  asset-generic at-xid-6a015391e15a28970b01bb08caaed2970d img-responsive\"><a href=\"http:\/\/villagebim.typepad.com\/files\/mouchvillagebim.dyn\">T\u00e9l\u00e9chargement Fichier Dynamo<\/a><\/span><\/p>\n<p style=\"text-align: justify\">&#160;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voil\u00e0, je vous avais promis de m\u2019investir dans le script Python, c\u2019est en partie chose faite ! Attention, je commence donc c&#039;est un exemple qui d\u00e9bute tout doucement. Voici l\u2019exemple: il s\u2019agit d\u2019un Moucharabieh soit un motif r\u00e9p\u00e9titif. Il va falloir recopier ce motif suivant une boucle de type \u201cFor\u201d, d\u2019o\u00f9 l\u2019utilisation du code python. [&hellip;]<\/p>\n","protected":false},"author":4760,"featured_media":2472,"menu_order":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[15,17,6],"tags":[13,20,171,865,21,1313],"class_list":["post-899","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-autodesk-revit","category-nouveautes","category-trucs-et-astuces","tag-autocad","tag-autodesk","tag-dynamo","tag-exemple-dynamo","tag-revit","tag-script-python","dhig-theme--light"],"acf":[],"_links":{"self":[{"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/posts\/899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/users\/4760"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/comments?post=899"}],"version-history":[{"count":0,"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/posts\/899\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/media\/2472"}],"wp:attachment":[{"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/media?parent=899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/categories?post=899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.autodesk.com\/villagebim\/wp-json\/wp\/v2\/tags?post=899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}