Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
FeatureScript makeArray with index value
Rootentity
Member Posts: 21 ✭✭
I would like a clean way to fill an array on creation with reference to the current cell being filled without using a for loop to do it.
Example:
var myValue = 10;
const myArray = makeArray(10, myValue * i);
with the result being [0,10,20,30,40,50,60,70,80,90]
Example:
var myValue = 10;
const myArray = makeArray(10, myValue * i);
with the result being [0,10,20,30,40,50,60,70,80,90]
Tagged:
0
Comments
If you need numbers that aren't linear, you can call mapArray on a linear range. e.g.
The non-linear case is probably slower than a simple for loop – but profiling would say for sure.