Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Determine a solid body that contains an edge
daniel_cravens
Member Posts: 29 ✭
I would like to create a split normal feature that will splits a body with a normal plane containing an edge. The user selects the edge. I want to find the body that contains the user selected edge. But I can't figure out how to get just the solid body without also picking up the origin planes.
***
***
annotation { "Feature Type Name" : "Split Normal" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Select edge for split.", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }
definition.edge is Query;
}
{
var endPoints is Query = qAdjacent(definition.edge, AdjacencyType.VERTEX, EntityType.VERTEX);
var point1 is Vector = evVertexPoint(context, {
"vertex" : qNthElement(endPoints, 0)
});
var point2 is Vector = evVertexPoint(context, {
"vertex" : qNthElement(endPoints, 1)
});
var body = qIntersection(qEverything(EntityType.BODY)->qContainsPoint(point1),qEverything(EntityType.BODY)->qContainsPoint(point2));
debug(context,body);
});0
Best Answer
-
daniel_cravens Member Posts: 29 ✭This is what I ended up using:
var body = qBodyType(qEverything(EntityType.BODY), BodyType.SOLID)->qContainsPoint(point1);
***annotation { "Feature Type Name" : "Split Normal" }export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)precondition{annotation { "Name" : "Select edge for split.", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }definition.edge is Query;}{var endPoints is Query = qAdjacent(definition.edge, AdjacencyType.VERTEX, EntityType.VERTEX);var point1 is Vector = evVertexPoint(context, {"vertex" : qNthElement(endPoints, 0)});var point2 is Vector = evVertexPoint(context, {"vertex" : qNthElement(endPoints, 1)});var midPoint is Vector = point2 - point1;var body = qBodyType(qEverything(EntityType.BODY), BodyType.SOLID)->qContainsPoint(point1);var face = qOwnedByBody(body, EntityType.FACE)->qContainsPoint(point1)->qContainsPoint(point2);
// Create Plane Normal to Edgevar tangentLine = evEdgeTangentLine(context, {"edge" : definition.edge,"parameter" : 0.5});var tangentPlane = evFaceTangentPlane(context, {"face" : face,"parameter" : vector(0.5, 0.5)});var normal is Vector = cross(tangentPlane.normal,tangentLine.direction);var plane = opPlane(context, id + "plane1", {"plane" : { "origin" : point1,"normal" : normal,"x" : tangentLine.direction}});debug(context, plane);
// Split Body/*opSplitPart(context, id + "splitPart1", {"targets" : body,"tool" : plane});*/0
Answers
var body = qBodyType(qEverything(EntityType.BODY), BodyType.SOLID)->qContainsPoint(point1);
***
// Create Plane Normal to Edge
// Split Body