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:

Bitbybit Platform

A spiral of points, one curve through them in Rete

rete logoRete
Script Source (rete)
{
"id": "rete-v2-json",
"nodes": {
"spiral": {
"id": "spiral",
"name": "bitbybit.point.spiral",
"customName": "spiral",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"phi": 0.9,
"numberPoints": 200,
"widening": 3,
"radius": 6,
"factor": 1
},
"inputs": {},
"position": [
40,
40
]
},
"curve": {
"id": "curve",
"name": "bitbybit.occt.shapes.wire.interpolatePoints",
"customName": "interpolate points",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"periodic": false,
"tolerance": 1e-7,
"parametrization": "chordLength"
},
"inputs": {
"points": {
"connections": [
{
"node": "spiral",
"output": "result",
"data": {}
}
]
}
},
"position": [
460,
40
]
}
},
"modules": {}
}

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.