Skip to main content

Lists in every editor

Much of what a script handles comes in lists: the points of a curve, the faces of a solid, the copies of a part. Two different things can happen to a list, and it helps to tell them apart.

A list as one value​

Some functions want a whole list. bitbybit.occt.shapes.wire.interpolatePoints takes a list of points and makes one curve through all of them; bitbybit.occt.booleans.difference takes one shape and a list of shapes to cut from it. The list travels as a single value, exactly like a number would.

Here bitbybit.point.spiral makes a list of two hundred points, and one curve is made through them:

A spiral of points, one curve through them
Bitbybit Platform

A spiral of points, one curve through them in Rete

rete logoRete

Drawing a list of points draws every point; drawing a list of shapes draws every shape.

Once per item​

Other times you want a function to run once for each item: a sphere at every point, a fillet on every part. Each editor says that in its own way:

  • TypeScript uses the language: points.map(...) or a for loop, with await Promise.all(...) when the function is a kernel call.
  • Blockly has loops: the repeat and for-each blocks of its loops category run the blocks inside them for every item.
  • Rete repeats a component on its own: when several wires feed one input, the component runs once per value, every value against every value or paired 1:1. Lists and node options shows how, and the badges that say what a component received.

Reshaping lists​

The bitbybit.lists functions read and reshape lists in every editor: take an item or a range, reverse, flatten nested lists, group, pair. Lists introduces them.