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 query lines or edges where parts meet or intersect in FS?

Asher_EdwardsAsher_Edwards Member Posts: 6 EDU
edited May 2023 in FeatureScript
So this is my first feature script because I haven't been able to find a tool that does what I want. I can do this with several normal extrudes, but I thought it would be a good exercise for me to get into feature script.

This is my plan:

I am almost done with my feature script, but I haven't been able to implement the last feature I want. I'm talking about the checkbox that is for "Creating walls all around," and when that is unchecked.
I need some help implementing this feature. It seems like it shouldn't be that hard, but I'm having troubles understanding more advanced queries. I'm looking to have the walls that intersect with the part stay, but the shell walls that reach beyond to be discarded and/or not be created at all. I'm not sure what queries or evaluations plus operations would get this result. I think I need to query the edge where the intermediate part meets the main part. Then that edge can be turned into a plane and thickened into a wall.

I also need help dealing with inner closed loops such as holes. It is a problem with the query that gets outside edges.

Finally, and this isn't that important, does anyone have a better name for this other than "Pocket Shell"? :)

Document:
https://cad.onshape.com/documents/c4fb7c3adbe5270e2b2877d9/v/7c1f6944972c7a99527c5563/e/d26768d160e39ceedb863443


Best Answers

  • Asher_EdwardsAsher_Edwards Member Posts: 6 EDU
    Answer ✓
    So I have solved the first part of my question. I have the feature script remove the sketch face through the main part and that creates the desired edges on the main part. I then query for all edges created by the removal extrude, owned by the main part, and on the plane that the selected face is on.

    Query:
    //query for edges created by extrude 2 but owned by the original part
    var edgesByExtrude is Query = qOwnedByBody(qCreatedBy(id + "extrude2", EntityType.EDGE), definition.booleanScope);
    //Find the topmost edges by getting the first plane that the faces selected are on.
    edges = qCoincidesWithPlane(edgesByExtrude, evPlane(context, { "face" : evaluateQuery(context, definition.entities)[0] }));

    These edges are then feed into opRuledSurface, and then opThicken.




  • Asher_EdwardsAsher_Edwards Member Posts: 6 EDU
    Answer ✓
    So I have used qCapEntity, but that was only to help measure the extrude distance so I could remove material later.

    Currently the indent direction is based solely on the sketch normal, and a swap direction button. I bet it is difficult to have an indent that has its direction tangent to the plane. My feature script is currently working on any linear surface. Slight problems occasionally pop up, like extra faces on the geometry, or swapped normals on one of the many faces selected.


    Note the extra faces in the middle. This is probably because I create a new body before merging into the part, and the faces overlap exactly. The replace face technique sounds interesting, I'll have to see if it eliminates the extra surfaces too.

    Items on my list to add in the future: Draft, scaling the end, transforming the end, adding manipulator handles, working with odd shaped surfaces (curves), fillet results, and adding a wrapper for boolean subtracting bodies with wall thickness. I'll get to them when I can, but I think I've almost reached the completion point for my original goal.

    It's exciting creating my first useful tool for myself and others!

    BTW I solved the inner loops problem by creating surfaces for all enclosed edge regions and removing that through the body.


Answers

  • S1monS1mon Member Posts: 2,982 PRO
    This reminds me a little of the "indent" feature in Solidworks. It takes a tool body and a target body. The target typically has a thin wall, and the tool body pushes (indents) the wall in. Your feature takes the sketch, extrudes it into the tool body, and then creates the indent. If you enabled adding draft to the extrusion, that would be pretty useful. There are a lot of options in the Solidworks version, but the offset and wall thickness parts were the most useful to me. Boolean subtract in Onshape will take an offset in a similar way.
  • Asher_EdwardsAsher_Edwards Member Posts: 6 EDU
    Thank you for the suggestions. I personally haven't deemed draft a necessary feature, but I suppose there would be uses by other users. Boolean subtract basically does the same thing the 2nd extrude does in my current version of the feature.
  • Asher_EdwardsAsher_Edwards Member Posts: 6 EDU
    Answer ✓
    So I have solved the first part of my question. I have the feature script remove the sketch face through the main part and that creates the desired edges on the main part. I then query for all edges created by the removal extrude, owned by the main part, and on the plane that the selected face is on.

    Query:
    //query for edges created by extrude 2 but owned by the original part
    var edgesByExtrude is Query = qOwnedByBody(qCreatedBy(id + "extrude2", EntityType.EDGE), definition.booleanScope);
    //Find the topmost edges by getting the first plane that the faces selected are on.
    edges = qCoincidesWithPlane(edgesByExtrude, evPlane(context, { "face" : evaluateQuery(context, definition.entities)[0] }));

    These edges are then feed into opRuledSurface, and then opThicken.




  • EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
    I actually set out to make something like this a year or so ago because I still miss the Indent feature from Solidworks. I lost steam on it because it was a deceptively tricky problem, but I've gotten a lot better at FS since then, so maybe it wouldn't be too tough now. In any case, if you made one I'd use it.

    Are you aware of qCapEntity()? Use it with opExtrude() (and some other functions) to get the start and/or end, but not the sides, or qNonCapEntity() for the sides. It can get edges or faces via the entityType field, but my first thought would be to get the faces and use Replace Face.

    I recommend considering your flow using the standard Onshape featureset. I imagine that a Replace Face feature might be the best way to get the face flush in the way you want. Here's an example of one way that seems pretty good.
    Evan Reese
  • Asher_EdwardsAsher_Edwards Member Posts: 6 EDU
    Answer ✓
    So I have used qCapEntity, but that was only to help measure the extrude distance so I could remove material later.

    Currently the indent direction is based solely on the sketch normal, and a swap direction button. I bet it is difficult to have an indent that has its direction tangent to the plane. My feature script is currently working on any linear surface. Slight problems occasionally pop up, like extra faces on the geometry, or swapped normals on one of the many faces selected.


    Note the extra faces in the middle. This is probably because I create a new body before merging into the part, and the faces overlap exactly. The replace face technique sounds interesting, I'll have to see if it eliminates the extra surfaces too.

    Items on my list to add in the future: Draft, scaling the end, transforming the end, adding manipulator handles, working with odd shaped surfaces (curves), fillet results, and adding a wrapper for boolean subtracting bodies with wall thickness. I'll get to them when I can, but I think I've almost reached the completion point for my original goal.

    It's exciting creating my first useful tool for myself and others!

    BTW I solved the inner loops problem by creating surfaces for all enclosed edge regions and removing that through the body.


Sign In or Register to comment.