What it does
This powerful node identifies and groups sequences of items (shapes or shape trees) based on user-defined expressions. It enables pattern-based grouping, making it easier to structure and process related elements in your template.
Use it for
- Grouping items that follow a specific pattern or logical sequence.
- Common use cases include:
- Grouping lines of text into paragraphs.
- Segmenting repeated layout patterns.
- Creating groups of items based on their index in the input list.
- Grouping items of a section.
How to use it
- Drag and drop the node from the Node Library into your template:
Node Library > Folder Shapes > Folder Grouping - Connect the node with other nodes in the Data Flow of your template.
- Specify the settings in the Node Properties task pane.
Node Input
Connect a node from the Data Flow that contains the items (shapes or shape trees) in which you want to find sequences to the Items input port. These items are analyzed to detect sequences based on the configured expressions.
Node Output
This node provides two outputs, visible in the Node Result task pane:
- Sequences: A list of shape trees, each representing a detected sequence. Each shape tree contains the grouped items.
- Remainder: A list of items that were not included in any sequence, because they didn’t match the defined expressions.
You can connect both output ports individually to other nodes for further processing.
Node Properties
Node Name
You can assign a custom name to the node to help identify its purpose within your template.
Sequence Name
You can assign a custom name to the newly created sequences to help identify them in further processing.
Sequence Start Expression
A condition that identifies the first item of a sequence.
Available variables:
-
item: the current item being processed from the input list.itemhas the same properties as a shape tree object. -
index: the zero-based index of the item in the input list -
first: the first item in the input list -
last: the last item in the input list -
prev: the previous item in the input list.prevhas the same properties as a shape tree object. -
next: the next item in the input list.nexthas the same properties as a shape tree object. -
count: the total number of items in the input list
Expected return type: boolean
Important
You must enter the Sequence Start Expression, the Sequence Member Expression, and the Sequence End Expression, before you can view the result in the Node Result task pane.
Sequence Member Expression
A condition that identifies items that belong to the same sequence after the start item.
Available variables:
-
item: the current item being processed from the input list.itemhas the same properties as a shape tree object. -
index: the zero-based index of the item in the input list -
first: the first item in the input list -
last: the last item in the input list -
prev: the previous item in the input list.prevhas the same properties as a shape tree object. -
next: the next item in the input list.nexthas the same properties as a shape tree object. -
count: the total number of items in the input list
Expected return type: boolean
Sequence End Expression
A condition that marks the end of a sequence.
Available variables:
-
item: the current item being processed from the input list.itemhas the same properties as a shape tree object. -
index: the zero-based index of the item in the input list -
first: the first item in the input list -
last: the last item in the input list -
prev: the previous item in the input list.prevhas the same properties as a shape tree object. -
next: the next item in the input list.nexthas the same properties as a shape tree object. -
count: the total number of items in the input list
Expected return type: boolean
Examples
Example 1: grouping text lines into paragraphs
You have already created a list of shape trees, each containing individual text lines. Your goal is to detect paragraphs and group the lines accordingly. In the layout the distance between the last line of one paragraph and the first line of the next is greater (more than 3 points) than the distance between lines within the same paragraph (less than 2 points).
Sequence Start Expression
first or prev.bottom _ item.top > 3.0
The first item of a sequence is either:
- the first item in the input list, or
- an item where the vertical gap between the bottom edge of the previous item and the top edge of the current item is greater than 3.0 points.
Sequence Member Expression
prev.bottom _ item.top < 2.0 and item.bottom _ next.top < 2.0
An item belongs to an ongoing sequence if:
- the vertical gap between the previous item and the current item is less than 2.0 points, and
- the gap between the current item and the next item is also less than 2.0 points.
Sequence End Expression
last or item.bottom _ next.top > 3.0
The last item of a sequence is either:
- the last item in the input list, or
- an item where the vertical gap between its bottom edge and the top edge of the next item is greater than 3.0 points.
Example 2: grouping items based on their index
You have a list of items and want to create two groups:
- The first group should contain the first 5 items.
- The second group should contain the next 10 items.
Sequence Start Expression
index in [0,5]
A sequence starts either with:
-
the first item in the input list (
index = 0), or -
the sixth item in the input list (
index = 5).
Sequence Member Expression
true
All items between the start and end of the sequence are included.
Sequence End Expression
index in [4,14]
A sequence ends either with:
-
the fifth item in the input list (
index = 4), or -
the fifteenth item in the input list (
index = 14).
Example 3: grouping sections based on item names
You have a sorted structure containing headings and paragraphs from your document. Now, you want to group all items that belong to each main heading. Items that represent main headings have the name Heading1.
Sequence Start Expression
item.name = "Heading1"
A sequence starts with an item whose name is Heading1.
Sequence Member Expression
true
All items between the start and end of the sequence are included.
Sequence End Expression
last or next.name = "Heading1"
A sequence ends either with:
- the last item in the input list, or
-
an item whose next item has the name
Heading1.
Example 4: grouping items by page
This example demonstrates how to group items that reside on the same page by comparing their respective document page indices.
Sequence Start Expression
first or document.pages[prev.pages[0].index].index < document.pages[item.pages[0].index].index
The first item of a sequence is either:
- the first item in the input list, or
- The page index of the previous item is less than that of the current item.
Note: Since shape trees may span multiple pages, the page index used for comparison is derived from the first page on which any shape within the shape tree appears.
Sequence Member Expression
true
All items between the start and end of the sequence are included.
Sequence End Expression
last or document.pages[item.pages[0].index].index < document.pages[next.pages[0].index].index
A sequence ends either with:
- the last item in the input list, or
- The page index of the current item is less than that of the next item.
Note: As with the Sequence Start Expression, if a shape tree spans multiple pages, the first page on which any shape appears is used as the reference for determining the document page index.