<?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>Manipulate Lists/Array</title><link>https://communities.bentley.com/products/products_generativecomponents/f/generativecomponents---forum/159523/manipulate-lists-array</link><description>Hi All, 
 Just wondering if anyone could help with a question on manipulating a list/array. 
 An example of what I am trying to do is select a row of building envelope elements or multiple rows based on a variable. 
 For example selecting every 3 rd row</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Manipulate Lists/Array</title><link>https://communities.bentley.com/thread/477248?ContentTypeID=1</link><pubDate>Mon, 20 Aug 2018 07:55:17 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:7d46ba05-5bcd-463d-95c9-b22ffe299967</guid><dc:creator>Wayne Dickerson</dc:creator><description>&lt;p&gt;Thanks Ingo,&lt;/p&gt;
&lt;p&gt;I will have a look at that thread.&lt;/p&gt;
&lt;p&gt;For anyone interested in the Second part and a method of placing polygons on alternating or different spacing for I have attached an example file I created to test out my facade options. (work in progress as always :))&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Wayne&lt;/p&gt;
&lt;p&gt;&lt;a href="https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/360/PolyEveryNthFloor.dgn"&gt;communities.bentley.com/.../PolyEveryNthFloor.dgn&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manipulate Lists/Array</title><link>https://communities.bentley.com/thread/477239?ContentTypeID=1</link><pubDate>Mon, 20 Aug 2018 07:26:40 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:9cb6a76f-c447-4281-bdd3-e06be18604f4</guid><dc:creator>Ingo</dc:creator><description>&lt;p&gt;Hi Wayne,&lt;/p&gt;
&lt;p&gt;I had a simple example some days ago concerning a &amp;#39;correctly&amp;#39; labeled pointlist where Volker showed &amp;#39;the right way&amp;#39;.&lt;/p&gt;
&lt;p&gt;I think &lt;a href="/products/products_generativecomponents/f/generativecomponents---forum/159100/point-grid-by-function---correctly-labeled/476434#476434"&gt;there&lt;/a&gt; you can get the solution for your first question.&lt;/p&gt;
&lt;p&gt;Ingo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manipulate Lists/Array</title><link>https://communities.bentley.com/thread/477233?ContentTypeID=1</link><pubDate>Mon, 20 Aug 2018 06:56:12 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:5093b892-3a0a-4b3a-97fa-9ebcac6e31a6</guid><dc:creator>Wayne Dickerson</dc:creator><description>&lt;p&gt;Update:&lt;/p&gt;
&lt;p&gt;I think I worked out the second part.&lt;/p&gt;
&lt;p&gt;using the Sublist I could specify the range(count) and return the desired rows of points every Nth spacing&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;function (Point[][] pntarray, int dRow, int dSpan)
{
    Point returnlist = {};

    for (int i = 0; i &amp;lt; pntarray.Count; i += dRow)
    {
    returnlist.Add(pntarray.Sublist(i,dSpan));

    }

    return returnlist;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;actually ended up as a simple function call.&lt;/p&gt;
&lt;p&gt;let me know if you can see any improvements&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Wayne&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manipulate Lists/Array</title><link>https://communities.bentley.com/thread/477224?ContentTypeID=1</link><pubDate>Mon, 20 Aug 2018 06:22:29 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:206dbf91-bca0-4d1a-b4b7-de993acc359e</guid><dc:creator>Wayne Dickerson</dc:creator><description>&lt;p&gt;Hi Volker,&lt;/p&gt;
&lt;p&gt;Thanks for the pointers. (insert joke here)&lt;/p&gt;
&lt;p&gt;One thing I overlooked was that I managed to input a 0 value for dRow which puts it into an infinite loop.&lt;/p&gt;
&lt;p&gt;So I add an &amp;ldquo;if&amp;rdquo; statement around the loop&amp;nbsp;as a&amp;nbsp;safeguard. I think this is the best way to do it.&lt;/p&gt;
&lt;p&gt;if (dRow &amp;gt; 0 &amp;amp;&amp;amp; dItem &amp;gt;0)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have 2 questions:&lt;/p&gt;
&lt;p&gt;The return list is a flat list rather than an array, so if wanted to use the point as for a Polygon ByPointGrid it will error.&lt;/p&gt;
&lt;p&gt;Is there an easy way to output the results as an array rather than a list?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The second question is if I needed to select 2 or 3 rows of points ever N rows? How would I go about writing a script for this.&lt;/p&gt;
&lt;p&gt;I first thought I would need to find i being the first row of points I needed then adding a variable for the number of rows I needed about this say 3. Then loop again and find the next i and so on.&lt;/p&gt;
&lt;p&gt;I have attached a picture to try and explain. Using this we could alternate fa&amp;ccedil;ade panels every 3 floors.&lt;/p&gt;
&lt;p&gt;So far I have the following: (which is obviously wrong but starting somewhere :) )&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;function (Point[][] pntarray, int dRow, int dItem, int dSpan)

{

Point returnlist = {};

int j=0;

// I believe this int j=0 needs to be within the for loop as it needs to reset for each loop.

if (dRow &amp;gt; 0 &amp;amp;&amp;amp; dItem &amp;gt;0)

{

    for (int i = 0; i &amp;lt; pntarray[i].Count; i += dRow+j)

    //while (j &amp;lt; dSpan) ??

        {

        for (int k =0; k &amp;lt; pntarray[i].Count; k += dItem)


        returnlist.Add(pntarray[i][k]);

        // j ++; ??

        }

}

return returnlist;

}
&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The other approach I had was to select each row separately and then combine them in a ToList expression&lt;/p&gt;
&lt;p&gt;{point1[0],point1[1],point1[2]}.ToList()&lt;/p&gt;
&lt;p&gt;And&lt;/p&gt;
&lt;p&gt;{point1[2],point1[3],point1[4]}.ToList()&lt;/p&gt;
&lt;p&gt;Etc&lt;/p&gt;
&lt;p&gt;And then place combine these back into 1 list with another ToList() which works perfectly for what I need for the output but it feels very manual. I am sure there is a way to achieve this via a script.&lt;/p&gt;
&lt;p&gt;Or alternatively I could have used:&lt;/p&gt;
&lt;p&gt;{point1.Sublist(0,3),point1.Sublist(2,3)}.ToList()&lt;/p&gt;
&lt;p&gt;Which is much more refined, and looking at it you could probably for statement with a increment of 2 and a variable for the count. Maybe this is the best approach for this.&lt;/p&gt;
&lt;p&gt;Any tips would be appreciated&lt;/p&gt;
&lt;p&gt;Thanks&lt;br /&gt; Wayne&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Manipulate Lists/Array</title><link>https://communities.bentley.com/thread/476465?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 21:22:50 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:0b3ff1c4-094f-404c-ac43-d19d746f838e</guid><dc:creator>Mueller</dc:creator><description>&lt;p&gt;Hi Wayne,&lt;/p&gt;
&lt;p&gt;For a one-dimensional list you could use the list method &amp;quot;MembersAt&amp;quot;. If your list is food = {potato, egg, cucumber, broccoli, fish, steak}, then food.MembersAt({1,3,5}) is {potato, cucumber, fish}.&lt;/p&gt;
&lt;p&gt;For multi-dimensional lists, you&amp;#39;d have to iterate through the nested&amp;nbsp;lists; however, instead of recreating the items you want to select you could add them to a list of the type:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;function (Point[][] pntarray, int dRow, int dItem)
{
    Point returnlist = {};
    for (int i = 0; i &amp;lt; pntarray.Count; i += dRow)
    {
        for (int j = 0; j &amp;lt; pntarray[i].Count; j += dItem)
        {
            returnlist.Add(pntarray[i][j]);
        }
    }
    return returnlist;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This function code would reside in a FunctionCall node (or could be a named Script Function created in and added to the Functions dialog).&lt;/p&gt;
&lt;p&gt;Additional refinements could be to add startRow and startItem and change the loops to start at those values, respectively, i.e. for (int&amp;nbsp;i&amp;nbsp;= startRow; &amp;hellip; .&lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Volker&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>