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.

Variable Array

I have been trying to make a variable array, but did not succeed. Can anyone tell me how to do it?
Tagged:

Best Answer

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,658
    A "Variable" that is an array of values, or a linear/circular array of geometric features that can be varied? "Variables" can only hold a single value.

    If it is a geometry problem, please post an image or link to your public doc, thanks.
    Senior Director, Technical Services, EMEAI
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,658
    So they can! I stand corrected - that's what happens when you don't read the help! Now I'll have to find a good use for it.....
    Senior Director, Technical Services, EMEAI
  • SquidLordSquidLord Member Posts: 15 ✭✭
    NeilCooke said:
    So they can! I stand corrected - that's what happens when you don't read the help! Now I'll have to find a good use for it.....
    From a programmatic point of view, they probably won't be terribly useful until that array can be populated by data taken from within the sketch itself (not as useful as it sounds), or from an outside data supply – like a spreadsheet or other external source.

    That will open up a lot of possibilities with a named data source and offsets into that matrix. I'd also like to see dictionaries (arrays which essentially use a string as an index rather than an integer) because you can structure a lot of useful data space by doing so, but I fully expect to be waiting a while for that one.
  • _Ðave__Ðave_ Member, Developers Posts: 712 ✭✭✭✭
    @esa_hietikko  Here is a simple block using a variable array. HTH

     Simple Block Doc
  • esa_hietikkoesa_hietikko Member Posts: 2 EDU
    Thanks, worked now. I made a test with a bolt (public document Hex-Bolt-DIN-931) and found out that if you change the array values the instances used in assemblies change a well. So you need to make a copy for each size used in assemblies.
  • Cyndi_HilsabeckCyndi_Hilsabeck Member Posts: 2
    So is it NOT possible to use a (x) Variable for an Array Pattern?  Seems like it should work, but the field won't accept the variable text.
  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    @Cyndi_Hilsabeck, you definitely can do this for a pattern feature, but you're right. A sketch pattern won't allow you to input a variable. Time for an enhancement request. In the meantime, there aren't many things you can accomplish with a sketch pattern that you can't do with either a part, face, or feature pattern.
  • alexander_visakayalexander_visakay Member Posts: 17 ✭✭
    So is it NOT possible to use a (x) Variable for an Array Pattern?  Seems like it should work, but the field won't accept the variable text.
    Does anyone know if this has been added yet or a work around? 
  • tim_hess427tim_hess427 Member Posts: 648 ✭✭✭✭
    @alexander_visakay - I don't believe it's possible to user variables in sketch patterns due to some fundamental ways that sketches work (there are some other discussions on the forums you should be able to find). If you used a variable in a sketch pattern to draw some holes (like in the example above), then the subsequent extrude feature would break because the number of selections in the extrude feature would change. I don't think there's a good way to have downstream features adjust to changing numbers of closed sections in sketches.

    My understanding is that if you need to use variables in a pattern, you should sketch and extrude the one hole, and then use a face or feature pattern with the appropriate variables. 
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
    edited October 2021
    You can create the extrusion and then an array of that feature or faces...

    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • alexander_visakayalexander_visakay Member Posts: 17 ✭✭
    @tim_hess427 Thanks, I see that I can add a variable to a pattern on a feature. Odd workaround but if it works i'll live with it
  • robert_stilesrobert_stiles Member Posts: 115 PRO
    mmm, I agree this is odd. Considering all the other things Onshape can do, this just seems like an oversight? If I define a variable as a Number, to me it seems logical to be able to call this as the number of instances on a linear pattern. 
  • alnisalnis Member, Developers Posts: 452 EDU
    @robert_stiles here is some previous discussion of the matter, including an in-depth developer response:
    https://forum.onshape.com/discussion/comment/30219#Comment_30219

    In short, Onshape is designed to always regenerate deterministically (i.e. same parameters ==> same result). Onshape also allows modifying instances of sketch patterns, for example deleting certain ones. The problem here is that if you:
    1. Make a sketch pattern driven by a variable
    2. Edit/delete some instances
    3. Change the variable to a lower value (so the edited/delete instances are no longer present)
    4. Increase the variable again
    ... produces a problem: since the edited entities are destroyed when decreasing the pattern count, increasing the variable back to its original value will produce a different result, leading to non-deterministic regeneration.
    Get in touch: contact@alnis.dev | My personal site: https://alnis.dev
    @alnis is my personal account. @alnis_ptc is my official PTC account.
  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    Personally, I would prefer to have the option to use a variable to drive sketch pattern instances. Even if the implementation ends up not being deterministic due to the ability to delete sketch pattern entities, the behavior would still be logical and predictable. This is how SW does it, and it makes perfect sense to me. It would just be a caveat that users need to be aware of; if you drive instances with a variable, then don't delete instances under threat of spontaneously regenerating them.
Sign In or Register to comment.