Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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.

ARRAY VARIABLES

shawn_crockershawn_crocker Member, OS Professional Posts: 884 PRO
I'm having a hard time creating an array that has a dimensional size defined by another variable
    var partCount = size(evaluateQuery(context, definition.sheetMetalParts));
    var flatSizes = [partCount];
When I try to store things into flatSizes, [0] dimension takes a value but when the code loops back to store something in [1], I get a "Array index 1 out of bounds.".  It feels like I not defining the array size properly.

flatSizes[i] = getExtents(boundingBox, 3, inch);That is how I'm trying to store the map values.  I'v been searching and am not finding clear answers on this one.

Best Answer

  • Alex_KempenAlex_Kempen Member Posts: 248 EDU
    edited June 2021 Answer ✓
    You're currently making an array containing the variable partCount. Accordingly, flatSizes always contains a single element, so it always has a size of 1. To make flatSizes properly, use makeArray instead.
    Software Developer at Epic Systems
    FRC Design Mentor - Team 1306 BadgerBots


Answers

  • Alex_KempenAlex_Kempen Member Posts: 248 EDU
    edited June 2021 Answer ✓
    You're currently making an array containing the variable partCount. Accordingly, flatSizes always contains a single element, so it always has a size of 1. To make flatSizes properly, use makeArray instead.
    Software Developer at Epic Systems
    FRC Design Mentor - Team 1306 BadgerBots


  • shawn_crockershawn_crocker Member, OS Professional Posts: 884 PRO
    @Alex_Kempen your a life saver. Thanks again.
Sign In or Register to comment.