{"id":222,"date":"2016-11-23T20:34:20","date_gmt":"2016-11-23T19:34:20","guid":{"rendered":"http:\/\/pythoncvc.net\/?p=222"},"modified":"2017-09-20T18:16:15","modified_gmt":"2017-09-20T17:16:15","slug":"revit-add-sizes-to-a-pipe-segment-using-python-dynamo","status":"publish","type":"post","link":"https:\/\/pythoncvc.net\/?p=222","title":{"rendered":"[Revit] Add sizes to a pipe segment using python + Dynamo + Excel"},"content":{"rendered":"<p>I didn&rsquo;t want to use Dynamo as I really prefer line code programming to visual programming. But in fact Dynamo :<\/p>\n<ul>\n<li>has a very active community<\/li>\n<li>is open source too<\/li>\n<li>use python as main scripting language<\/li>\n<li>is great for debugging python script as you don&rsquo;t need to include every single line in a try\/except block<\/li>\n<li>is much user friendly than as it is now included with Revit 2017.1 and by the way this new Dynamo Player makes it usable by anyone<\/li>\n<li>scare many people less than line code so they can easily modify to adapt it to their objectives<\/li>\n<\/ul>\n<p>Here is the Dynamo image. It uses <a href=\"https:\/\/github.com\/andydandy74\/ClockworkForDynamo\">Clockwork package<\/a> :<\/p>\n<p><a href=\"https:\/\/pythoncvc.net\/wp-content\/uploads\/2016\/11\/AjouterTaillesSegmentsTuyaux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-225 size-large alignnone\" src=\"https:\/\/pythoncvc.net\/wp-content\/uploads\/2016\/11\/AjouterTaillesSegmentsTuyaux-1024x501.png\" alt=\"ajoutertaillessegmentstuyaux\" width=\"620\" height=\"303\" srcset=\"https:\/\/pythoncvc.net\/wp-content\/uploads\/2016\/11\/AjouterTaillesSegmentsTuyaux-1024x501.png 1024w, https:\/\/pythoncvc.net\/wp-content\/uploads\/2016\/11\/AjouterTaillesSegmentsTuyaux-300x147.png 300w, https:\/\/pythoncvc.net\/wp-content\/uploads\/2016\/11\/AjouterTaillesSegmentsTuyaux-768x376.png 768w, https:\/\/pythoncvc.net\/wp-content\/uploads\/2016\/11\/AjouterTaillesSegmentsTuyaux-620x303.png 620w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<p>File is available <a href=\"https:\/\/github.com\/CyrilWaechter\/pythoncvc.net\/blob\/master\/RevitPyCVC\/Dynamo\/SegmentsTuyaux_AjouterTailles.dyn\" target=\"_blank\" rel=\"noopener\">here<\/a><\/p>\n<p>Here is the python code block :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">import clr\r\nclr.AddReference(\"RevitAPI\")\r\nfrom Autodesk.Revit.DB import *\r\nfrom Autodesk.Revit.DB.Plumbing import PipeSegment\r\n\r\nclr.AddReference(\"RevitServices\")\r\nfrom RevitServices.Persistence import DocumentManager\r\nfrom RevitServices.Transactions import TransactionManager\r\n\r\ndoc = DocumentManager.Instance.CurrentDBDocument\r\n\r\n#Les entr\u00e9es effectu\u00e9es dans ce noeud sont stock\u00e9es sous forme de liste dans les variables IN.\r\ndataEnteringNode = IN\r\n\r\nelem = doc.GetElement(IN[0])\r\n\r\nTransactionManager.Instance.EnsureInTransaction(doc)\r\n\r\nfor dn, di, de in zip(IN[1], IN[2], IN[3]):\r\n\tDN = UnitUtils.ConvertToInternalUnits(dn , DisplayUnitType.DUT_MILLIMETERS)\r\n\tDi = UnitUtils.ConvertToInternalUnits(di , DisplayUnitType.DUT_MILLIMETERS)\r\n\tDe = UnitUtils.ConvertToInternalUnits(de , DisplayUnitType.DUT_MILLIMETERS)\r\n\ttry:\r\n\t\telem.AddSize(MEPSize(DN,Di,De,True,True))\r\n\texcept:\r\n\t\telem.RemoveSize(DN)\r\n\t\telem.AddSize(MEPSize(DN,Di,De,True,True))\r\n\t\t\r\n#Affectez la sortie \u00e0 la variable OUT.\r\nOUT = IN<\/pre>\n<p>Enjoy<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I didn&rsquo;t want to use Dynamo as I really prefer line code programming to visual programming. But in fact Dynamo : has a very active community is open source too use python as main scripting language is great for debugging python script as you don&rsquo;t need to include every single line in a try\/except block [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[125,80,38],"tags":[127,44,52,129,82,131],"class_list":["post-222","post","type-post","status-publish","format-standard","hentry","category-dynamo-en","category-python","category-revit-en","tag-dynamo-en","tag-hydraulic","tag-mep-en","tag-pipesegment-en","tag-python","tag-revit-api-2017-en"],"_links":{"self":[{"href":"https:\/\/pythoncvc.net\/index.php?rest_route=\/wp\/v2\/posts\/222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythoncvc.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythoncvc.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythoncvc.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythoncvc.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=222"}],"version-history":[{"count":5,"href":"https:\/\/pythoncvc.net\/index.php?rest_route=\/wp\/v2\/posts\/222\/revisions"}],"predecessor-version":[{"id":327,"href":"https:\/\/pythoncvc.net\/index.php?rest_route=\/wp\/v2\/posts\/222\/revisions\/327"}],"wp:attachment":[{"href":"https:\/\/pythoncvc.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythoncvc.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythoncvc.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}