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.
Variable Array
esa_hietikko
Member Posts: 2 EDU
I have been trying to make a variable array, but did not succeed. Can anyone tell me how to do it?
Tagged:
0
Best Answer
-
@NeilCooke I don't believe that is correct, the Documentation has a section on using arrays. You enter the array as [a,b,c,etc][x] where x is the position of the value you want (starts at 0). Notably, a,b,c and x can be variables so you can make things pretty complex.
As soon as we get variables derived from sketch elements this opens up a LOT of paremetric possibilities.7
Answers
-
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, EMEA0 -
@NeilCooke I don't believe that is correct, the Documentation has a section on using arrays. You enter the array as [a,b,c,etc][x] where x is the position of the value you want (starts at 0). Notably, a,b,c and x can be variables so you can make things pretty complex.
As soon as we get variables derived from sketch elements this opens up a LOT of paremetric possibilities.7 -
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, EMEA0
-
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.3
-
@esa_hietikko Here is a simple block using a variable array. HTH
Simple Block Doc0 -
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.0
-
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.
2 -
@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.1
-
Does anyone know if this has been added yet or a work around?Cyndi_Hilsabeck said: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.
0 -
@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.0 -
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ún0 -
@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 it0
-
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.0
-
@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:- Make a sketch pattern driven by a variable
- Edit/delete some instances
- Change the variable to a lower value (so the edited/delete instances are no longer present)
- Increase the variable again
Get in touch: contact@alnis.dev | My personal site: https://alnis.dev
@alnis is my personal account. @alnis_ptc is my official PTC account.1 -
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.0









