Learn what a list is and how to use them.
What is a list?
Lists in Lists
Lists of One (1)
What is a list and list processing?
All blocks in nTopology can exist as singular entities or as a list. A list contains multiple items of the same type in a single block, like a list of points. When a process runs on a list block, it runs the process on every list item. Working with list blocks is called List Processing.
To create a list of any type, type ‘list’ into the search bar, along with the block type you would like to create. Lists are denoted in nTopology by three small rectangles of increasing width in the bottom left corner of the data type icon. The size of a list is shown in parentheses next to the Block type. Not all lists are created from the search bar, some are made unintentionally or automatically with certain blocks. Some blocks turn a singular entity into a list and some merge lists together.
If you get an 'invalid input error', it may be because you are trying to input a list into a singular type input.
Input List Length Mismatch is another common list error. This occurs when you have at least two inputs, each with a list of different lengths. This can also appear when a List of (1) is unintentionally created.
Lists in Lists - Inputting a list block within another list block
A list block can't be input into another list block.
However, if you want to input a list into a block that doesn't accept lists, you can create a Custom Block to run the list instead. This works because the inputs of a notebook are contained in variables, and variables cannot process lists. However, once it's being used as a Custom Block, it's a block like any other and therefore can process lists. This is not equivalent to putting the list into the input but rather running the Custom Block workflow multiple times, once for each element in the list.
Check out an example of this here.
List block properties contain a set of List properties at the top and individual properties for each item within the list at the bottom. The individual properties can be dragged out of a List to create an individual item. The dropdown arrow next to the individual entities can be expanded to reveal more information on that individual list entity. You can click and drag the individual chips into the notebook to create a new single variable separated from the list.
There are two methods to add blocks to a list:
- Drag a new block into a List block. Remember that all entities in a list must have the same block type (i.e. they must have the same icon in the top left corner of the block).
- Select the '+' to add more inputs. If you add too many, use the '-' on the left of the input to remove them.
The order of list entities can be changed by dragging list entities around within the List block.
Other list manipulation tools are in the Utilities Ribbon Tab, under ‘General’. These blocks are outlined below.
- List Element: Extract a single entity from a list based on its index number.
- Insert: Combine two lists into one by inserting a list into another at a specified index location.
- Sub List: Extract a smaller list from a larger input list, based on a starting index and the desired size of the sub-list.
- Remove: Remove one or more entities from a list, based on a starting index and the number of removed entities.
Some blocks use list inputs and combine them into a singular entity. An example of this is the Boolean Union block, which takes in a list of bodies and generates a single unioned body. Blocks like this are auto-populated with an empty list, which is useful for quickly dragging bodies inside to complete the operation.
Sometimes, a user already has a list prepared that they would like to perform a boolean union operation on. In this case, the auto-populated list must be deleted and replaced by the desired list.
Lists of One (1)
You may encounter a situation where you try to add your parts to a block that accepts a list of inputs, and it won't let you.
This is because the input you are trying to add looks like "Block Name (1)". Somewhere, a List of One was created. Lists of one are sometimes unintentionally created by the user, or during CAD/Part importing. They can be converted to singular entities by either dragging the entity out of the Properties tab of the Info panel or by using the List Element block.
To drag the entity out, open up the Properties tab, expand until you find the part, and drag the part chip into the Notebook. This creates a block in the Notebook that doesn't have a list. You can also drag the chip out directly into an input.
Groups in nTop are the same thing as lists, except they can contain a combination of any block types. For example, the group below consists of a point, a sphere, and a cube. The same list manipulation operations described can be performed on groups.
1. Add a Sphere List (notice the list icon on top of the sphere icon).
2. Add a Sphere block into each input of the Sphere List. Change the x-value center point of each sphere to 0, 10, and 25 respectively. Then change the radius to 3, 5, and 8 mm.
3. Add a Walled TPMS block and insert the Sphere List into the Body input. This runs the operation on each object in the list.
Please sign in to leave a comment.