Query Expression Examples
In the following examples, we presume that:
- line01 is the name of a previously-defined Line node that is replicated (i.e., it contains child Line nodes).
- maxLength is the name of a previously-defined object that represents a maximum length. For example, maxLength could be an Expression node, a Slider node, a function argument, or a variable.
If we want: | We use this script: |
---|---|
A list composed of those child lines whose lengths are within the maximum length. |
from ln in line01 where ln.Length <= maxLength |
A list composed of all child lines, ordered by their lengths (smallest to largest). |
from ln in line01 orderby ln.Length |
A list composed of all child lines, ordered by their lengths (largest to smallest). |
from ln in line01 orderby ln.Length descending |
A list composed of the start points of the child lines. (Actually, in this case, it would be easier to just say line01.StartPoint!) |
from ln in line01 select ln.StartPoint |
A list composed of the start points of those child lines whose lengths are within the maximum length. |
from ln in line01 where ln.Length <= maxLength select ln.StartPoint |
A list composed of the X values of the start points of those child lines that do not exceed the maximum length, ordered from smallest to largest. |
from ln in line01 where ln.Length <= maxLength orderby ln.StartPoint.X select ln.StartPoint.X |
The largest length among the child lines. |
(from ln in line01 select ln.Length).Maximum() |
The largest length that does not exceed the maximum length. |
(from ln in line01 where ln.Length <= maxLength select ln.Length).Maximum() |
The child line that has the largest length. |
(from ln in line01 orderby ln.Length).Last() |
The three child lines that have the largest lengths. |
(from ln in line01 orderby ln.Length).Last(3) |
The start points of the three child lines that have the largest lengths. |
(from ln in line01 orderby ln.Length).Last(3).StartPoint |
The start points of the three child lines that have the largest lengths that do not exceed the maximum length. |
(from ln in line01 where ln.Length <= maxLength orderby ln.Length).Last(3).StartPoint |
Whether or not any child lines exceed the maximum length. (For example, in the context of a conditional expression (… ? … : …) or an ‘if’ statement.) |
(from ln in line01 where ln.Length > maxLength).Any() |
The number of child lines that exceed the maximum length. |
(from ln in line01 where ln.Length > maxLength).Count |
The total length of those child lines that do not exceed the maximum length. |
(from ln in line01 where ln.Length <= maxLength select ln.Length).Sum() |
The median X value of the start points of those child lines that do not exceed the maximum length. |
(from ln in line01 where ln.Length <= maxLength select ln.StartPoint.X).Median() |