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.

Options

patterns in assembly configurations

stvnvl_8501stvnvl_8501 Member Posts: 113 PRO
Hi,

I Can't seem to figure out how to adjust patterns to the assembly configurations. 
I've included a simplified example here
seems the variable studio variables with the same name as the configuration variables get overwritten,
so far so good.  
But variables that are later derived from these "overwritten" variables don't...?
as the number of bars in the grid and the spacing between them is a function of the height or width of the grid. this then doesn't change as shown in the picture below. the bars of the grid change effectively, but the grid doesn't expand. 

Is there a better way or workaround? 

thanks!  







Best Answer

  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,718 PRO
    edited June 2023 Answer ✓

    Yes, this is possible. Before we go further, you need to decide what you want your driving parameter to be. Total width and height, spacing between bars, or bar widths. It can be any 2 combinations of these, but all 3 at the same time will over-constrain unless they are the exact right numbers. I suggest Total width and bar width as the spacing between is easier to adjust than the size of the bars in the real world. Unless you want the total width to be the driving parameter and the spacing between to equal the bar spacing. 

    Personally, I would throw all of this into a single part studio so I could use more tools: feature variables, pattern along curve, custom features, etc... For me, assemblies are a pain to work with because I want theme to have all the same functionality as a part studio; they are worth it if you need to use the BOM or have large scale projects.

    Assuming you want the gaps to be as close as possible to the bar widths, but still vary to fit the over all size of the grid. You can do this which takes advantage of math functions within the feature input box. You could use roundToPrecision() but I used ceil() instead with will round it up to the nearest whole number.

    Note I removed all variables in the variable studio except the bar size.

    Quantity calculation
    ceil(#heightGrid/(#sizeBar*2))

    Spacing calculation
    (#heightGrid - #sizeBar)/ ((ceil(#heightGrid/(#sizeBar*2)))-1)

    Place both of these inside your assembly pattern and you should be good to go.

    https://cad.onshape.com/documents/de5523855733346e4095f92d/w/fbf477c3ec61e6d1170b5eb9/e/b...



    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎

Answers

  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,718 PRO
    edited June 2023

    Are you intentionally trying to override? Why not use different names to keep things clear and simple. You could also throw in some ternary conditional operators if you want to be able to use both and switch between them. 

    Ternary conditional operatiors + configurations + variable studio

    UseDefaultQty? DefaultQty: Qty




    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    stvnvl_8501stvnvl_8501 Member Posts: 113 PRO
    Hi @MichaelPascoe

    Thanks for the quick reply. 
    You've lost me. ternary conditional operators?
    the real application is a shelving unit which uses rollers on its shelf surface. 
    customers can change the width of this shelving to their specs. only thing they have to worry about is the width of the shelf, the system should be able to generate a shelving with the max number of rollers that their specific chosen width will accomodate. 

    anyway, back to the example: 
    so the only input available is width and height of the grid (through a config variable) 
    using the width/height config variable I can then calculate the distance between the beams to be as close to a desired value and stil get an even distribution. 
    This calculation is done in an number of formulas in the variable studio (as i don't see any other way) the input however is done through a config variable, which, to my knowledge isn't available to the variable studio (allthough it seems to override the variable studio variable with the same name) So yes, I am intentionally trying to get this value overwritten. challenge is, the overwritten value isn't used in later formulas in that same variable studio. 
    did you have a look at the example? 
    here's the link again: 
    https://cad.onshape.com/documents/3a8ab0d673782bfca533c900/w/37e4e9fbded6346ebfef801a/e/7aef2fcc51d641191a71013f

    thanks again! 

    PS: I should definately look into those ternary conditional variables, seems like a neat trick. 

  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,718 PRO
    edited June 2023

    Here is an improvement request that would allow what you are trying to do: 
    https://forum.onshape.com/discussion/21188/variable-studio-measured-variables#latest

    Ternary conditional operators are extremely helpful for creating variable patterns and models. They are a short hand version of the "if then statement" that you can use directly in the Onshape input boxes within features or variables. Here is a quick guide on how to use them:

    In this tutorial gif, you can see how to change the quantity of a pattern based on the diameter variable. If the diameter is less than 2in, use qty of 6. If the diameter is not less than 2in, use qty of 4.



    Logical Operators
    DescriptionOperator
    equal==
    greater than>
    less than<

    Modifiers
    not!
    and&&
    or||

    Operator Combinations
    less than or equal<=
    greater than or equal>=
    not equal!=
    not less than!<
    not greater than!>

    Ternary Conditional Operator Examples
    Return one value or different value depending on if the statement is true or false.
    logical statement ? value returned if statement is true : value returned if statement is false
    1 == 1 ? 999 : 555this returns the value 999 because 1 does equal 1
    1 == 2 ? 999 : 555this returns the value 555 because 1 does not equal 2
    1 != 1 ? 999 : 555this returns the value 555 because 1 does equal 1
    1 != 2 ? 999 : 555this returns the value 999 because 1 does not equal 2
    1 < 1 ? 999 : 555this returns the value 555 because 1 is not less than 1
    1 < 2 ? 999 : 555this returns the value 999 because 1 is less than 2
    1 <= 1 ? 999 : 555this returns the value 999 because 1 is less than or equal to 1
    1 <= 2 ? 999 : 555this returns the value 999 because 1 is less than or equal to 2
    1 <= 0 ? 999 : 555this returns the value 555 because 1 is not less than or equal to 0

    Combined Logical Statement Examples
    Use modifiers to combine multiple statements
    (1 == 1) && (2 == 2)This statement returns true only if both statements are true
    (1 == 1) || (2 == 2)This statent returns true if either of the statements is true

    Nested Ternary Conditional Operator Examples
    Place statements within parenthesis to nest them
    1 == 1 ? 999 : (1 == 2 ? 444: 333)Returns 999
    1 == 5 ? 999 : (1 == 2 ? 444: 333)Returns 333
    1 == 5 ? 999 : (1 == 1 ? 444: 333)Returns 444


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    stvnvl_8501stvnvl_8501 Member Posts: 113 PRO
    Hi @MichaelPascoe

    very inspriring. thanks! 

    I'm guessing getting all of the calculations in 1 ternary conditional operator would prove tricky, no? 

    in the example of the grid: 
    you have
    x number of bars,
    x-1 number of spaces between bars.
    distance from center tot center between bars = (dimension of bar+ space between)  
    width(1000)
    dimension of bar = (25)
    number of spaces between bars = number of bars-1
    distance to divide=1000-25=975
    minimim distance center-center bar: 100
    number of spaces= floor(975/100)=9
    number of bars= 9+1
    space between bars center-center= (975/9)
     
    so starting from 1000 as a config input, i would need these results (9+1) as a number (number of bars) and (975/9) as a length (step of the  lineair pattern)  to further use as variable. 
    does this make sense? 

    Regards, 
    Steven 

    PS i've also tried a workaround (inspired by skeleton modelling in several other CAD programs) where one would use a sketch or "dummy part" (seperate part studio loaded into the assembly) to be used as a skeleton/ framework to create instances of a part or subassembly using the "replicate" command

    allthough promising, replicate doesn't take mate connectors or sketch geometry as seed and only works in 1 plane. I guess this could also be used to generate a more complex pattern instead of just linear or circular repetitions. 


  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,718 PRO
    edited June 2023 Answer ✓

    Yes, this is possible. Before we go further, you need to decide what you want your driving parameter to be. Total width and height, spacing between bars, or bar widths. It can be any 2 combinations of these, but all 3 at the same time will over-constrain unless they are the exact right numbers. I suggest Total width and bar width as the spacing between is easier to adjust than the size of the bars in the real world. Unless you want the total width to be the driving parameter and the spacing between to equal the bar spacing. 

    Personally, I would throw all of this into a single part studio so I could use more tools: feature variables, pattern along curve, custom features, etc... For me, assemblies are a pain to work with because I want theme to have all the same functionality as a part studio; they are worth it if you need to use the BOM or have large scale projects.

    Assuming you want the gaps to be as close as possible to the bar widths, but still vary to fit the over all size of the grid. You can do this which takes advantage of math functions within the feature input box. You could use roundToPrecision() but I used ceil() instead with will round it up to the nearest whole number.

    Note I removed all variables in the variable studio except the bar size.

    Quantity calculation
    ceil(#heightGrid/(#sizeBar*2))

    Spacing calculation
    (#heightGrid - #sizeBar)/ ((ceil(#heightGrid/(#sizeBar*2)))-1)

    Place both of these inside your assembly pattern and you should be good to go.

    https://cad.onshape.com/documents/de5523855733346e4095f92d/w/fbf477c3ec61e6d1170b5eb9/e/b...



    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
Sign In or Register to comment.