<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>GC - Every Second Value from an Expression (for a Barrier Script)</title><link>https://communities.bentley.com/products/products_generativecomponents/f/generativecomponents---forum/209739/gc---every-second-value-from-an-expression-for-a-barrier-script</link><description>Hi All, 
 If I have an expression that contains a list of polygons, is there any way I can select every second value from that expression? In the script I am working on I have an expression that contains all the polygons that represent the start and end</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: GC - Every Second Value from an Expression (for a Barrier Script)</title><link>https://communities.bentley.com/thread/634152?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 08:08:34 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:cdf48409-ace8-4045-8e55-c960c26567aa</guid><dc:creator>Alifur Mandal</dc:creator><description>&lt;p&gt;Hello Ryan,&lt;/p&gt;
&lt;p&gt;As Ed has mentioned that if you are using Update 7 of OpenBuildings Designer then you can try to achieve the same using the Value &amp;amp; Operation node.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please have a look at the GCT file attached.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Alifur&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/360/even.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/360/Empty.gct"&gt;communities.bentley.com/.../Empty.gct&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GC - Every Second Value from an Expression (for a Barrier Script)</title><link>https://communities.bentley.com/thread/634140?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 03:26:14 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:1f9977cf-d6e3-460e-989c-2c8bd8c76552</guid><dc:creator>Ryan McCormack</dc:creator><description>&lt;p&gt;Thanks Ed,&lt;/p&gt;
&lt;p&gt;That does exactly what I wanted.&lt;/p&gt;
&lt;p&gt;Much appreciated.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Ryan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GC - Every Second Value from an Expression (for a Barrier Script)</title><link>https://communities.bentley.com/thread/634137?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 02:59:35 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:fcb804d3-6213-4bed-88b7-9ffcff6e784d</guid><dc:creator>Edward Ashbolt</dc:creator><description>&lt;p&gt;Hi Ryan,&lt;/p&gt;
&lt;p&gt;If you are using u7 you might be able to use the &amp;quot;Operator&amp;quot; node to achieve this, but it is simple enough to create a function if your list has a depth of 1 (no nested lists):&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/360/1220.Capture.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;function(object input)
{
    int output = {}; //create an output array
    int j = 0; //create a new starting index for the output array
    for(int i = 0; i &amp;lt; input.Count; ++i) //iterate through the input object
    {
        if(i % 2 != 0) //if the index number is odd
        {
            output[j] = input[i]; //return the value at that index
            ++j; //next index
        }
    }
    return output;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In your case you would want to change the type of the output variable to be a polygon instead of int. If you haven&amp;#39;t seen a modulus operator before, it is represented by a &amp;quot;%&amp;quot; symbol and is used to determine the amount left over if you divide by &amp;#39;x&amp;#39;; in this case we determine if i / 2 does not leave a remainder of 0, then it is an odd number.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;&lt;br /&gt;Ed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>