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.

How to automatically choose a configured assembly?

troy_ostrandertroy_ostrander Member Posts: 34 ✭✭
edited December 5 in General

An example would be with drawers in cabinetry. The drawer slide hardware have specific depths from 250 to 700mm. The drawer assembly including slide is easy to configure. How do you make an automation for the input of the inside depth of cabinet to choose the best fitting drawer assembly? The goal being change the cabinet depth and the drawer assembly updates to the best fitting drawer assembly.

Comments

  • Matthew_CurranMatthew_Curran Member, csevp Posts: 24 PRO
    edited December 8

    The way we do this is in part studios is through nested if statements, checking the input of the cabinet depth against the minimum size allowed for a specific slide, if true, return the correct slide/box size, if false, check the next smaller size. So that would look something like this.

    #Depth >= 25.*in ? 24.*in : ( #Depth >= 24*in ? 23*in : (#Depth >= 23*in ? 22*in : 0*in ) )

    So, if you setup this logic in your drawer and slide part studios, then you can pass in the depth variable through the assembly configuration and have the part studios calculate the size they need to be.

    I think. I haven't worked too much with assemblies.

  • troy_ostrandertroy_ostrander Member Posts: 34 ✭✭

    Thanks @Matthew_Curran for your reply. I'm familiar with nested if and statement. But rather than changing a dimension I'd want the true/false statement result be the actual configuration name. I know this is possible in SW.

    BTW I'm just starting with Onshape so I am lacking the Onshape terminology.

  • shawn_crockershawn_crocker Member, OS Professional Posts: 921 PRO

    @troy_ostrander Could you describe how you would do it in SW? Because @Matthew_Curran solution was not quite what your after, I'm, not positive what your after. I generally use the nested if route but in a configured variable studio. I like keeping that big messy nested logic out of my main assembly and in a place that is made for designing logic variables. If I knew what you were doing in SW, I think it would be more clear to me what you want. I have not found too many things in SW I could not accomplish in Onshape in terms of logic programming. Of course, we still cannot dynamically control suppression or booleans in assemblies yet but, I feeling like its just around the corner.

  • troy_ostrandertroy_ostrander Member Posts: 34 ✭✭

    Hi @shawn_crocker good to know that you have matched SW features in Onshape. I don't have access to Solidworks anymore so I can't show you the example unfortunately. But basically you can add logic to a Solidworks Excel Design Table in the column $CONFIGURATION@component <instance>. See screenshot whereas eg "500 movento" is the name of the configured component to be inserted.

    The goal is just to get a logic statement to a control insert of a configured component into an assembly. But I could totally be going around this in the wrong way and there's a better way to do it.

    chrome_d6WUek4TvT.png
  • shawn_crockershawn_crocker Member, OS Professional Posts: 921 PRO
    edited 12:27PM

    @troy_ostrander There different way to get what you want here. To keep it more similar to your example, I have set up a little doc that you can checkout here.

    In Onshape, there is a conditional logic capability that functions just like the excel formula if(condition, do if true, do if false).

    The way to do conditions is by using the same ternary logic that one would use in JavaScript. That is, condition ? do if true : do if false.

    So, you can write in any variable or configuration input variable,

    #depth < 20in ? "TOO SMALL" : (#depth < 100in ? 20in : (#depth < 150in ? 100in : (#depth < 200in ? 150in : 200in)))

    In the example doc, I have created a variable studio which I have configured. I did not have to do this but I wanted to demo a nice clean way to create more complicated logic in one place which allows propagating that logic cleanly in any place. Because I programmed the variable within the variable studio to react as intended to changes to the #LENGTH input, we can now drop that variable in all over the place if we want and anything being driven by it also reacts as intended. We do not have to copy and paste the text of that logic all over the place. We can just change that one variable studio and everything referencing it immediately has access to that newly edited logic. You can also lock references to that variable by switching items to reference a version of the variable studio. This way you have greater control over deciding when a particular item should start using the updated logic to the variable or not at all.

    Variable studios in Onshape were a game changer when they were introduced. However, I did not use them too much simply because I had sort of found other ways of doing things without globally accessible variables. Recently, when the ability to configure them was introduced, I suddenly found I can't stop finding ways to implement them and tidy up lots of complicated, duplicated logic that is scattered throughout my huge library of heavily configure company product models. Hope this helps some☺️

Sign In or Register to comment.