Select a portion of a series of arcs

Hi All,

This maybe a simple answer I may have missed in my reading but I thought I would ask 

I have a series of arc that are generated from a series of points along a line.

I would like to use a portion of the arcs for another process but cant work out how to select them. I can select individual arcs by say arc1[35] but how would I go about selecting the arcs say from arc1[01] to arc1[35] ?

I tried a range box but it didn't give me the response I was hoping for.

Any tips would be appreciated.

Thanks

Wayne

  • [Phew, third attempt should be a charm --I'll refrain from fancy formatting this time because that's when my browser collapsed the previous two times.]

    Hi Wayne,

    If we want to select constituent nodes or child nodes based on a range of indices, e.g. from starting index 7 to ending index 35 we can use a couple of List Methods which are available through the dot operator entered behind a list.  Any object into which you can index is treated by GenerativeComponents as a list.  In our case, arc1 is a list.  The list methods we can use are <list>.First(n1) and <list>.Last(n2), with n1 and n2 as valid "counts" for the respective lists.  The Expression to select arc1[7] through arc1[35] then is:

    arc1.First(36).Last(29)

    Because indexing is zero-based, arc1[35] is list member number 36 (index plus 1).  36 is an argument to the list method: First(); therefore, it is enclosed by round parentheses.  arc1.First(36) gives us arc1[0] through arc1[35].  This is a list of arcs to which we can apply the next list method, Last().  Because we want arc1[7] to be the start of our selection, we have to figure out how many arcs we want to grab from the end of this list so that arc1[0] through arc1[6] are excluded from this resulting list.  arc1[0] to arc1[6] are 7 list members from that list of 36.  36 minus 7 is 29.  This means from the list of the first 36 arcs we take the Last(29). 

    Alternatively we can use Query Expressions to achieve this type of selection.  Query expression make a range of operations available that exceed the capabilities of list methods.  More information about query expression are available in the GenerativeComponents Help > GCScript Programming > GCScript Language > Components of the GCScript Language > Expressions > Query Expressions. 

    Using query expressions "skip" and "take" we can select the same index range 7 through 35 from arc1 with:

    from a in arc1 skip 7 take 29

    The numbers 7 and 29 are count based as in the list methods.  "a" is an ad hoc local variable that GenerativeComponents uses to execute the query into the list "arc1".

    If you want to base your expressions on the indices (7 and 35) instead and make them variable, e.g. startIndex = 7 and endIndex = 35, then the two expression turn into:

    arc1.First(endIndex + 1).Last((endIndex + 1) - startIndex)

    and

    from a in arc1 skip startIndex take (endIndex + 1) - startIndex

    respectively.

    Please let me know whether you have any questions about this.

    HTH,

          Volker

       

    Answer Verified By: Wayne Dickerson 

  • Hi Volker,

    As always a fantastic response, I gave it a test run and it works just as you mention above.

    Thanks again
    Wayne

  • Hi Wayne,

    Glad I could help!

    Regards,

         Volker

       

  • Hi Wayne,

    Do you have any example script to short a list? I have a similar situation where I want to offset lines from a series of lines.

    Eg. I have lines called line1[0] to line1[98], I only want to use line1[10] to line1[15] for offset.

    I am pretty sure this is the exact same situation as yours. I went through Volker's solution but I am a beginner so hard to understand, an example script will be easy to understand.

    Regards,

    Jaimin Patel

  • Sure thing. 

    I will put something together and post it here for you. 

    Thanks

    Wayne