<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: I have problem with this loop and if statement in dynamo (python scripts) in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9865486#M30463</link>
    <description>&lt;P&gt;Input data from get.itematindex is in var[] and output I looking for is string because I will used to match with my family name&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 18:35:03 GMT</pubDate>
    <dc:creator>somphon</dc:creator>
    <dc:date>2020-11-12T18:35:03Z</dc:date>
    <item>
      <title>I have problem with this loop and if statement in dynamo (python scripts)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9865363#M30461</link>
      <description>&lt;P&gt;I am beginner in writing python scripts in revit dynamo. I really need to used both for loop and if else statement together in one node to identify rebar size but when I run these code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&amp;nbsp;clr&lt;BR /&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&amp;nbsp;math&lt;BR /&gt;clr.&lt;SPAN&gt;AddReference&lt;/SPAN&gt;(&lt;SPAN&gt;'ProtoGeometry'&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&amp;nbsp;Autodesk.DesignScript.Geometry&amp;nbsp;&lt;SPAN&gt;import&lt;/SPAN&gt;&amp;nbsp;*&lt;BR /&gt;&lt;BR /&gt;clr.&lt;SPAN&gt;AddReference&lt;/SPAN&gt;(&lt;SPAN&gt;"RevitAPI"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&amp;nbsp;Autodesk&lt;BR /&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&amp;nbsp;Autodesk.Revit.DB&amp;nbsp;&lt;SPAN&gt;import&lt;/SPAN&gt;*&lt;BR /&gt;&lt;BR /&gt;clr.&lt;SPAN&gt;AddReference&lt;/SPAN&gt;(&lt;SPAN&gt;"RevitServices"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&amp;nbsp;RevitServices&lt;BR /&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&amp;nbsp;RevitServices.Persistence&amp;nbsp;&lt;SPAN&gt;import&lt;/SPAN&gt;&amp;nbsp;DocumentManager&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;doc = DocumentManager.Instance.CurrentDBDocument&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#The inputs to this node will be stored as a list in the IN variables.&lt;/SPAN&gt;&lt;BR /&gt;Size = IN[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;&lt;BR /&gt;Bartype = []&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&amp;nbsp;i&amp;nbsp;&lt;SPAN&gt;in&lt;/SPAN&gt;&amp;nbsp;Size:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p = []&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;if&lt;/SPAN&gt;&amp;nbsp;Size ==&amp;nbsp;&lt;SPAN&gt;"9"&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&amp;nbsp;&lt;SPAN&gt;"RB-9"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;elif&lt;/SPAN&gt;&amp;nbsp;Size ==&amp;nbsp;&lt;SPAN&gt;"12"&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&amp;nbsp;&lt;SPAN&gt;"DB-12"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;elif&lt;/SPAN&gt;&amp;nbsp;Size ==&amp;nbsp;&lt;SPAN&gt;"16"&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&amp;nbsp;&lt;SPAN&gt;"DB-16"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;elif&lt;/SPAN&gt;&amp;nbsp;Size ==&amp;nbsp;&lt;SPAN&gt;"20"&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&amp;nbsp;&lt;SPAN&gt;"DB-20"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;elif&lt;/SPAN&gt;&amp;nbsp;Size ==&amp;nbsp;&lt;SPAN&gt;"25"&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&amp;nbsp;&lt;SPAN&gt;"DB-25"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;elif&lt;/SPAN&gt;&amp;nbsp;Size ==&amp;nbsp;&lt;SPAN&gt;"28"&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&amp;nbsp;&lt;SPAN&gt;"DB-28"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;elif&lt;/SPAN&gt;&amp;nbsp;Size ==&amp;nbsp;&lt;SPAN&gt;"32"&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&amp;nbsp;&lt;SPAN&gt;"DB-32"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;elif&lt;/SPAN&gt;&amp;nbsp;Size ==&amp;nbsp;&lt;SPAN&gt;"40"&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&amp;nbsp;&lt;SPAN&gt;"DB-40"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;else&lt;/SPAN&gt;:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&amp;nbsp;&lt;SPAN&gt;"n/a"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Bartype.&lt;SPAN&gt;append&lt;/SPAN&gt;(p)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Assign your output to the OUT variable.&lt;/SPAN&gt;&lt;BR /&gt;OUT = Bartype&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I obtain only n/a, while my input data have those numbers (my data is import from excel)&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 Nov 2020 17:58:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9865363#M30461</guid>
      <dc:creator>somphon</dc:creator>
      <dc:date>2020-11-12T17:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: I have problem with this loop and if statement in dynamo (python scripts)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9865382#M30462</link>
      <description>&lt;P&gt;Not fluent in Python but thought this may be a Type disparity.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is your '&lt;SPAN&gt;Size' variable a string or an integer?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The values you are looking for are in quotes whcih indicates to me a string Type.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 18:03:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9865382#M30462</guid>
      <dc:creator>TheRealChrisHildebran</dc:creator>
      <dc:date>2020-11-12T18:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: I have problem with this loop and if statement in dynamo (python scripts)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9865486#M30463</link>
      <description>&lt;P&gt;Input data from get.itematindex is in var[] and output I looking for is string because I will used to match with my family name&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 18:35:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9865486#M30463</guid>
      <dc:creator>somphon</dc:creator>
      <dc:date>2020-11-12T18:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: I have problem with this loop and if statement in dynamo (python scripts)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9866639#M30464</link>
      <description>&lt;P&gt;To be precise my data from excel come into double[] and python scripts I write intended to compared between each double[] data from my excel with certain integer such as Size == 12: This mean that IN[0] that goes into Size will be tested with if statement if its true I would like to print a string "DB-12". so according to my data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Size = Double[] contains 16,20,25,32,12,9&lt;/P&gt;&lt;P&gt;goes into my python scripts my expected result is&lt;/P&gt;&lt;P&gt;BarType = String[] contains "DB-16","DB-20","DB-25","DB-32","DB-12","DB-9"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it somehow didnt detect any syntax but result came out to be BarType = "n/a","n/a","n/a","n/a","n/a","n/a" for all test which shouldn't happen. n/a is false statement where int in double[] didnt match any of true statement. My true statement have 12 16 20 25 28 32 40 which normally should match since I intentionally used only number that match with true statement. which I presume that my python scripts will add input as double[] and output as string[]&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 08:04:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9866639#M30464</guid>
      <dc:creator>somphon</dc:creator>
      <dc:date>2020-11-13T08:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: I have problem with this loop and if statement in dynamo (python scripts)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9874181#M30465</link>
      <description>&lt;P&gt;Your code is wrong. It should be like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for i in Size:
    p = []
    if i == "9":  # not Size == "9". "i" is the item you shoud check in every loop iteration.
        p = "RB-9"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it helped, please check it as solved.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 03:43:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/i-have-problem-with-this-loop-and-if-statement-in-dynamo-python/m-p/9874181#M30465</guid>
      <dc:creator>nur91m</dc:creator>
      <dc:date>2020-11-17T03:43:31Z</dc:date>
    </item>
  </channel>
</rss>

