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: 128 PRO
edited December 17 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: 471 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: 128 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: 471 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: 128 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: 471 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: 128 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: 471 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: 128 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

Sign In or Register to comment.