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.

tableArray() vs table()

EvanReeseEvanReese Member, Mentor Posts: 2,798 PRO

I'm working on a feature that produces a table, but would like subsequent instances of that feature to add additional tables instead of overwriting the last one. Cutlist has the behavior I want. I see that it uses tableArray() and creates multiples in one go by iterating over the composite bodies made by the Cutlist feature and getting the table from each which was stored as an attribute by Cutlist. That defineTable() returns a TableArray, but I'm getting the error that "Return value should be Table, was TableArray" even though the documentation says it should be able to return either. Any ideas or examples I can look at?

Evan Reese
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com

Best Answer

  • Caden_ArmstrongCaden_Armstrong Member Posts: 384 PRO
    Answer ✓

    I'm looking for a public sample (I have some private ones I can share directly with you) for the forum knowledge base…

    But have you defined the correct return type?

    export const bendTable = defineTable(function(context is Context, definition is map) returns TableArray

    if you copy pasted a single table feature that has "returns Table", that might be your problem.

    www.smartbenchsoftware.com --- Renaissance --- fs.place
    Experts in Onshape Automation - Custom Features and Integrated Applications

Answers

  • Caden_ArmstrongCaden_Armstrong Member Posts: 384 PRO
    Answer ✓

    I'm looking for a public sample (I have some private ones I can share directly with you) for the forum knowledge base…

    But have you defined the correct return type?

    export const bendTable = defineTable(function(context is Context, definition is map) returns TableArray

    if you copy pasted a single table feature that has "returns Table", that might be your problem.

    www.smartbenchsoftware.com --- Renaissance --- fs.place
    Experts in Onshape Automation - Custom Features and Integrated Applications
  • EvanReeseEvanReese Member, Mentor Posts: 2,798 PRO
    edited February 3

    That was 100% it, thanks Caden! If I hadn't been trying to do it with my last brain fumes of the day I suppose I could have realized that's exactly what the error message is telling me 🤦‍♂️

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
Sign In or Register to comment.