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.
Featurescript - in a sketch how to determine if point is on a face
ian_mctavish
Member Posts: 7 EDU
in General
I'm trying to create a featurescript that creates a 1" grid of points on a face. If the selected face is parallel to the top plane I can easily find the minimum and maximum x and y values. What I am struggling with is if the face is in a different orientation - how do I determine the minimum/maximum values of x and y in relation to the sketch?
0
Comments
If you are trying to find if a point is on a face, you have two options:
qContainsPoint(face,point)
, and then check if the query is empty withisQueryEmpty()
or
evDistance()
and check if the face/point distance is zeroIf you want to find the bounds of the face, you can use
evBox3d()
, and specify the coordinate system of the sketch.Without knowing the specifics of what you are trying to accomplish, hard to know which to recommend, but that should help at least a little bit.
Custom FeatureScript and Onshape Integrated Applications
Caden,
Thanks, I am trying qContainsPoint. Here is the code I am using:
//facePlane is Plane tangent to the selected face: definition.targetFace
//definition.targetFace is a query from a face that the user selects
var vectorToCheck is Vector = planeToWorld(facePlane, vector(0,0)*inch);
var pointToCheck = toWorld(planeToCSys(facePlane), vectorToCheck);
println(qContainsPoint(definition.targetFace, pointToCheck));
println("");
println(isQueryEmpty(context, qContainsPoint(definition.targetFace, pointToCheck)));
Now vectorToCheck should be on the face, however I am getting true for the isQueryEmpty (full output below). Thanks for any insights you can provide.
{ point : [ 1.1102230246251565e-16 , 0 , 0.006350000000000001 ] , queryType : CONTAINS_POINT , subquery : { queryType : UNION , subqueries : [ { disambiguationData : [ { disambiguationType : ORIGINAL_DEPENDENCY , originals : [ { entityType : EDGE , historyType : CREATION , operationId : [ Fo1W4E0qGbUNqs8_0.wireOp ] , queryType : SKETCH_ENTITY , sketchEntityId : g1bWyhonVgaM.bottom } , { entityType : EDGE , historyType : CREATION , operationId : [ Fo1W4E0qGbUNqs8_0.wireOp ] , queryType : SKETCH_ENTITY , sketchEntityId : g1bWyhonVgaM.top } , { entityType : EDGE , historyType : CREATION , operationId : [ Fo1W4E0qGbUNqs8_0.wireOp ] , queryType : SKETCH_ENTITY , sketchEntityId : g1bWyhonVgaM.left } , { entityType : EDGE , historyType : CREATION , operationId : [ Fo1W4E0qGbUNqs8_0.wireOp ] , queryType : SKETCH_ENTITY , sketchEntityId : L8eKFDnIzZjc0.MirrorCS } , { entityType : EDGE , historyType : CREATION , operationId : [ Fo1W4E0qGbUNqs8_0.wireOp ] , queryType : SKETCH_ENTITY , sketchEntityId : 7Wii66VG1rhd0.MirrorCS } , { entityType : EDGE , historyType : CREATION , operationId : [ Fo1W4E0qGbUNqs8_0.wireOp ] , queryType : SKETCH_ENTITY , sketchEntityId : Je0q0qDnAOdG0.MirrorCS } ] } ] , entityType : FACE , historyType : CREATION , isStart : false , operationId : [ Fu4c1LKMRjZ3SBK_0.opExtrude ] , queryType : CAP_FACE } ] } }
true
Have you done addDebugPoint and addDebugEntity to see if the point you are checking really is on the target face?
You can also sanity check with evDistance and see if the distance is zero.
Custom FeatureScript and Onshape Integrated Applications
I got it working - I should have used vectorToCheck instead of pointToCheck. Thanks so much!