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.

Custom Feature: Split with Sketch

ry_gbry_gb Member, csevp, pcbaevp Posts: 144 PRO
edited December 20 in Using Onshape

— Link to the feature —

This is technically the first script I ever made after going through the tutorials in the Feature Script documentation, so it's probably pretty crude. However, I've used it enough that it's probably time to put it out there, until someone else comes along and creates a better implementation for it. It's simple enough that anyone could do it, but all I saw were requests for it and no features, so here we are.

"But Ramon? Why do we need this? Can't you just extrude a surface and use that to split your part?" Yes and I HATE doing that every time.

Some notes:

  • What this feature actually does is Extrude a surface with a Through all condition on both sides. That surface splits the target part, with Keep tools turned off, since we're ✌️splitting with a sketch✌️.
  • opSplit doesn't take multiple inputs and so this feature doesn't either. If you'd want to split with multiple sketch lines, the best way to do so is to connect the lines at the moment. If there's enough interest, I could try to iterate through the input queries.
  • Keep both sides is turned off by default because I always have to uncheck it 90% of the time. (Edit: Remember previous value is also enabled).

Ramon Yip | glassboard.com

Comments

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 488 PRO

    @ry_gb UIHint.REMEMBER_PREVIOUS_VALUE remembers the last user input from the session. Good to throw that in there for length values or settings you need to reapply for a drafting montage. I always forget to add that to my features until I need to run 20 of them in a studio and then get annoyed at myself and update the script.

  • ry_gbry_gb Member, csevp, pcbaevp Posts: 144 PRO

    It's in there. I dropped it in there right after I typed the sentence, but before I hit Post.

    Ramon Yip | glassboard.com

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 488 PRO
    edited December 17

    Ah I see an issue with implementing multi split the easy way. Keep Both Sides would delete everything if the sketches were set up just right (or wrong). Hang on I've got the sauce for that.

    Edit: I see now why multiple splits by sketch is not a thing in the core library. Keeping subsets of splits is kinda tricky when you need to know prior to full execution how many segments will exist and where. Dang Editing Logic runtime constraints.

  • ry_gbry_gb Member, csevp, pcbaevp Posts: 144 PRO
    edited December 17

    So you mean that my simple monkey brain solution of "just use for loops" for everything is gonna have pretty big downstream issues?

    I wonder how SolidWorks does it. I guess you get prompted multiple times in the feature dialog, so they're probably running additional logic after additional user input.

    Ramon Yip | glassboard.com

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 488 PRO

    Well the only problems come from situations where you want to remove bodies with the split. You can't select the subsegments to keep in the UI because they don't exist yet, so I was gonna do my Better Than Boolean UI magic to let you select the sub-regions but my keep all and invert selections rely on instancing that isn't stable with opSplit from my trials.

    Dumb monkey mode for splitting works great provided you always keep all regions.

  • ry_gbry_gb Member, csevp, pcbaevp Posts: 144 PRO

    Ohhhhhh… I see. You mean if you're choosing sides to keep… In my brain all the sides were already there, not even thinking about the fact that we just talked about leaving keep sides off by default. You're just streets ahead on this.

    Ramon Yip | glassboard.com

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 488 PRO

    I think I'm going to take a break from complex engine implementation problems for a minute and roll back to a version that just keeps all regions always because that's going to be the most representative use case for me. Save the brain power for surface tween.

  • ry_gbry_gb Member, csevp, pcbaevp Posts: 144 PRO

    Probably for the better. This feature was literally just because I hate extruding surfaces solely for the purpose of splitting objects. It's really no different than Split in Inventor.

    Excited to see where you end up for Surface Tween.

    Ramon Yip | glassboard.com

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 488 PRO

    Here's my version with multisplit support. Sidestepped the whole keep sides dilemma and nightmare of figuring out how to develop the UI for that because actually my team will only ever be using this in cases where you want to keep all of the split regions. Can always just delete the bits after if you need to.

  • ry_gbry_gb Member, csevp, pcbaevp Posts: 144 PRO

    Lol do I just need to start scripts for you to add your magic dust and make them 3x better? Not a complaint, just appreciation (especially since I also get to learn from it as well).

    Also, is conditional visibility based on the query count possible in the precondition?

    Ramon Yip | glassboard.com

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 488 PRO

    Apparently. Some of the stuff you've been getting into has been in my backlog forever or running a parallel track to what I've been working on so it helps kick off new ideas when I've got the starting point.

    I'm not sure I've seen a script that had conditional visibility based on object count. The workarounds I've usually seen have been to start a different tab that does multi mode or to do two different scripts for single vs multi.

  • ry_gbry_gb Member, csevp, pcbaevp Posts: 144 PRO
    edited December 18

    Gotcha. Two different tabs might be an okay workaround for this.

    Glad to be the catalyst of new ideas.

    Ramon Yip | glassboard.com

  • ry_gbry_gb Member, csevp, pcbaevp Posts: 144 PRO

    I went ahead and merged both options through the use of separate tabs. Thanks @Derek_Van_Allen_BD for implementing multi-split!

    Ramon Yip | glassboard.com

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 488 PRO

    Any time man. You loop my utils, I'll loop yours.

Sign In or Register to comment.