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.

Logic Driven Switch Configuration

troy_ostrandertroy_ostrander Member Posts: 77 ✭✭

Is this possible in Onshape?

Comments

  • EvanReeseEvanReese Member, Mentor Posts: 2,807 PRO
    edited February 4

    I think the answer is probably yes, but I'm not 100% sure what you're asking. Do you mean something like if #myValue > 5 set the length to 10 and if not set it to 7?

    I made a video series that might help about all of the ways to build logic into your part studios. Since the creation of those you can also drive feature suppression with an expression, which gives this kind of thing way more power.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • troy_ostrandertroy_ostrander Member Posts: 77 ✭✭

    HI @EvanReese thanks for your video series. I am new to Onshape and was exploring what is possible. I was hoping for someone to point me in the right direction. It could be that this is not possible yet in Onshape. That would be good to know too.

    I am trying automate best fitting drawer slide hardware. I can get the logic statement to work but instead of the result being a value, I need the result to switch configuration.

    Here is example logic of it producing the correct value

    (#DEPTH >= 750 mm ? 750 mm : (#DEPTH >= 700 mm ? 700 mm : (#DEPTH >= 650 mm ? 650 mm : (#DEPTH >= 600 mm ? 600 mm : (#DEPTH >= 550 mm ? 550 mm : (#DEPTH >= 520 mm ? 520 mm : (#DEPTH >= 500 mm ? 500 mm : (#DEPTH >= 480 mm ? 480 mm : (#DEPTH >= 450 mm ? 450 mm : (#DEPTH >= 420 mm ? 420 mm : (#DEPTH >= 400 mm ? 400 mm : (#DEPTH >= 380 mm ? 380 mm : (#DEPTH >= 350 mm ? 350 mm : (#DEPTH >= 320 mm ? 320 mm : (#DEPTH >= 300 mm ? 300 mm : (#DEPTH >= 270 mm ? 270 mm : (#DEPTH >= 250 mm ? 250 mm : 0 mm )))))))))))))))))

    https://cad.onshape.com/documents/b9b3305a3ad2b3f2f803f97f/w/a0c42c2ad2127870732aa6e6/e/c7404778e9603741aab5f2f9

  • EvanReeseEvanReese Member, Mentor Posts: 2,807 PRO

    Ah! I see what you're up to there. There's not a way to actually select a different configuration via logic like this, but you can drive so much of your design via logic that perhaps you don't need to use an actual configuration. What leads you to want to change the configuration vs just changing values in your model based on logic?

    It looks like your ternaries work, but this problem is a good job for a binary search algorithm and featurescript. I have run into similar issues in the past so I figured now is as good a time as any to make a custom feature for it. I'm out of time for today, but I'll post a video explanation shortly.

    Here's a link to get the custom feature.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • troy_ostrandertroy_ostrander Member Posts: 77 ✭✭

    Thanks @EvanReese OK thanks for the clarifcation. I am sure there is another way. "What leads you to want to change the configuration vs just changing values in your model based on logic?"

    I thought changing config is the only way to get the part number to the BOM. See screenshots. I can share this doc with you directly if it helps.

    The beam is controlled by values and brackets and mounts are imported geometry. Lets forget the imported geometry for now and focus on that how does one assign a part number to eg 750 value for the beam ? Then we can pass through ONLY this part number to the main assembly.

    BTW drawer slide depths Increments are not equal. They differ 20mm, 30mm and 50mm depending on specific part number.

    chrome_DGbykr4Ec2.png chrome_3RR63y99hs.png
  • EvanReeseEvanReese Member, Mentor Posts: 2,807 PRO
    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • EvanReeseEvanReese Member, Mentor Posts: 2,807 PRO

    I see. In your case, why not just configure the depth value by the configuration drop down so no one ever gets the chance to try #DEPTH = 323.599283mm? You can limit selectable options to you list of values. That way you could also configure the part numbers as you're doing now.

    If that isn't going to work, you can actually set the PN with a custom feature too if you want to go that route, but it's more complicated, and I'm not currently seeing the point of trying that here based on your example.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • troy_ostrandertroy_ostrander Member Posts: 77 ✭✭

    Thanks @EvanReese for the " Nearest list value" FS. So I took it to the next level with a "Auto PN Assignment" FS. (Thanks to Claude Sonnet 4.5)

    Here are the results:

    https://cad.onshape.com/documents/9625b82998a2f86e9f23a403/w/6dd35be56d16cb9825eadc4d/e/7ac9b05c5786e987a49652b6

    I've built out a bit more a complete workflow for testing so you would adjust "Project_Depth" in the variable Studio.

    I think it's convoluted process whereas I'd be much more straightforward to just have logic configuration switching at assembly level but for now I guess this is work around.

    chrome_L7s6BXIPl3.png
  • troy_ostrandertroy_ostrander Member Posts: 77 ✭✭
Sign In or Register to comment.