GenerativeComponents Help

Select

Returns a new list comprising those members of the given list that satisfy the given function.

object[] Select(object[] list, bool function(object member,
...) selector, ...)

Select is a very versatile Function in GC Script allowing the user to make a selection from any list of given inputs according to user defined criteria.

How to use it

a) One line format:

Select(numberList, bool function(double num){ return num
< 2.5);})

b) Multi-line format

bool function selector(double num)
{
	return num < 2.5;
};
double selectedList = Select(numList, selector);

Selection works by going through each member of the input array and testing to see if they fulfill or not the selection criteria. The user defines the selection criteria through a custom written function, defining the inputs to the function, how the selection is made, and what is returned.

Options

Optional additional function arguments can be passed into the selector function. Additional arguments to the function are placed after the selector.

Examples

A) Select points from array of points by X Values. Select X values less that maxHeight. maxHeight is supplied as an optional argument, in this case 10.5.

Select(pointArray, bool function(Point pt, double maxHeight){
return pt.X < maxHeight;}, 10.5)

B) Select points from an array of points by T values. Select T values between 0.3 and 0.8. (Currently it is not possible to access individual T values within an array of points in a function so this is a way around accessing them via the TopLevelPoint.)

Select(pointArray, bool function(Point pt){ return(pt.TopLevelFeature.T[pt.Index]
> 0.3 && pt.TopLevelFeature.T[pt.Index]  < 0.8);})

C) Selecting arrays according to their size. Select arrays if their count is greater than zero

int[][] valuesList = {{}};
valuesList [0] = {5, 6, 2, 6};
valuesList [1] = {};
valuesList [2] = {3,5,2};
valuesList = Select(valuesList, function(int currentIndex)
{ return currentIndex.Count > 0; });
PrintFormat("valuesList = {0}", valuesList); // output
{{5, 6, 2, 6} {3,5,2}}

D) Selecting nodes from list by node type and crudely Height. Node Type is Polygon and Z height of StartPoint is greater than 0.0.

Select(featureLists, bool function(Feature feature){ return
(feature.Type==typeof (Polygon) && feature.StartPoint.Z >
0.0);}))

E) Selecting features from List according to a property length. Arc has radius greater than two.

Select(arcList, bool function(Arc arc){ return (arc.Radius
> 2);}))