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.

qSketchRegion with filterInnerLoops

cory_isaacsoncory_isaacson Member, Developers Posts: 43 PRO
I am using the filterInnerLoops setting, and with for example a circle sketch embedded in a rectangle it works fine.

I have another use case where I have a 2nd rectangle embedded in a larger one, but they share one side (to cut a rectangular notch out of the larger rectangle). The filterInnerLoops does not work in this case. Shouldn't this still work, as the smaller rectangle is fully contained in the larger one (they just share an edge). If this doesn't work then I will have to do an extrude/remove, which can work but it's much more code to do that.

Best Answers

  • cory_isaacsoncory_isaacson Member, Developers Posts: 43 PRO
    edited March 2017 Answer ✓
    Thanks, I found the problem. I was using a bounding point for the smaller rectangle. When I use one that is inside it, it works fine.

    Clarification: Now I understand how this works. If I set a point in the larger rectangle, then it subtracts the smaller nested rectangle automatically. If I set a point that borders the smaller nested rectangle, then both are selected. If I set a point inside the smaller nested rectangle, then only the smaller one is selected. This would be a very good area to clarify in the documentation, with query examples to show how it works.

    I am able to make it work now, so that is very good.

Answers

  • cory_isaacsoncory_isaacson Member, Developers Posts: 43 PRO
    edited March 2017
    As a further question to this, is it possible to query just part of a sketch? In this case, the smaller rectangle. Then I could merge the 2 queries via qSubtraction.

    If not then I assume I need to make the smaller rectangle it's own sketch, query that using qSketchRegion and then extrude/remove that.

    Or could I make 2 sketches on the same plane, use qSubtraction to get just the larger rectangle without the smaller one and extrude that? That would be almost as nice as filterInnerLoops.
  • jon_sorrellsjon_sorrells Onshape Employees Posts: 51
    You may find this blog post interesting regarding the behavior of filterInnerLoops: https://www.onshape.com/cad-blog/extrude-logic-and-sketch-resilience
    The key takeaway is "Onshape will extrude the outermost loop AND any closed sketch loop that has an edge or vertex that touches (or crosses) the outermost loop."

    Is the sketch created by your script?  You could use skPolyline to create just the region that you want to extrude, and then extrude the sketch.  If the sketch already exists in the part studio, you could pick just the face you want instead of selecting the entire sketch.

  • cory_isaacsoncory_isaacson Member, Developers Posts: 43 PRO
    Thanks. How can you query for just the polyLine area and not the entire sketch? I there is a way to query a part of a sketch things get much easier. If it has to be a separate sketch I know what to do, just more code is all.
  • jon_sorrellsjon_sorrells Onshape Employees Posts: 51
    You can use something like qContainsPoint to filter your query to only a specific face of the sketch.
    qContainsPoint(qSketchRegion(id + 'sketch1', false), vector(0.5, 1.5, 0) * inch)


  • cory_isaacsoncory_isaacson Member, Developers Posts: 43 PRO
    Great, just what I needed.
  • cory_isaacsoncory_isaacson Member, Developers Posts: 43 PRO
    edited March 2017
    @jon_sorrells, this doesn't work, because any point that is part of the smaller rectangle is also part of the larger rectangle. Will loopBoundedFaces or something like that work? If not then I have no other way but to make 2 sketches, seems like more work that it should be.

    More info:
    I did try some things, and the only thing I can do is to use qSubtraction to get the smaller rectangle by itself. If I try and use qSubtraction to get the larger rectangle without the smaller one it won't work, because the point in qContaintsPoint is in both the smaller and larger rectangle. This is too bad, because that means I cannot just get the larger rectangle less the smaller one, and opExtrude once. Seems like the only option is to opExtrude both rectangles separately and boolean with subtract.

    It would be great to be able to do something like qSketchRegion with filterInnerLoops that works for this type of situation.
  • cory_isaacsoncory_isaacson Member, Developers Posts: 43 PRO
    edited March 2017 Answer ✓
    Thanks, I found the problem. I was using a bounding point for the smaller rectangle. When I use one that is inside it, it works fine.

    Clarification: Now I understand how this works. If I set a point in the larger rectangle, then it subtracts the smaller nested rectangle automatically. If I set a point that borders the smaller nested rectangle, then both are selected. If I set a point inside the smaller nested rectangle, then only the smaller one is selected. This would be a very good area to clarify in the documentation, with query examples to show how it works.

    I am able to make it work now, so that is very good.
Sign In or Register to comment.