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.
How to use qAdjacent with Sketch-entities?
timo_schmid
Member Posts: 36 EDU
in General
Hi everyone,
I'm trying to select all the adjacent vertices
to a sketch-Face, that are also part of a selected set of points. See
following code:
precondition<br> {<br> annotation { "Name" : "area", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }<br> definition.area is Query;<br> annotation { "Name" : "edge", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }<br> definition.vertex is Query;<br> <br> }<br> {<br> var vertices = qAdjacent(definition.area, AdjacencyType.VERTEX, EntityType.VERTEX);<br> var evvertices = evaluateQuery(context, vertices); <br> var match = qIntersection([vertices , definition.vertex]);<br> var evmatch = evaluateQuery(context, match);<br> println(evvertices);<br> println(evmatch);<br> });
When I select a Face of a body and one of the adjacent vertices, the Intersection query works and I get 1 match.
When doing the same with a sketch-face and one of its vertices, it doesn't work.
Does anyone know how this can be achieved for a sketch entity?
Thank you,
Thank you,
Timo
Tagged:
0
Best Answer
-
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565If you debug everything created by a sketch, you'll see that a sketch operation usually creates two things:1) Wire bodies for every sketch edge2) Surface bodies with faces for each enclosed sketch regionWhen you're select into definition.area, you click the face of a sketch surface body. When you're selecting into definition.vertex, selection precedence makes you most likely to choose the vertices owned by the wire bodies.
Since the two are on different bodies, qAdjacent doesn't consider them to be topologically adjacent. So this problem is more general than sketches: It would happen any time definition.area and definition.vertex are on different bodies.To solve this, you can get the 3D position of the selected point using evVertexPoint(...). From there, (assuming you still need this query) you can query forqContainsPoint(qAdjacent(definition.area, AdjacencyType.VERTEX, EntityType.VERTEX), evaluatedPoint)
1
Answers
Somehow the code is not displayed, so here it is:
<br>
precondition<br> {<br> annotation { "Name" : "area", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }<br> definition.area is Query;<br> annotation { "Name" : "edge", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }<br> definition.vertex is Query;<br> <br> }<br> {<br> var vertices = qAdjacent(definition.area, AdjacencyType.VERTEX, EntityType.VERTEX);<br> var evvertices = evaluateQuery(context, vertices); <br> var match = qIntersection([vertices , definition.vertex]);<br> var evmatch = evaluateQuery(context, match);<br> println(evvertices);<br> println(evmatch);<br> <br> <br> });<br>
Since the two are on different bodies, qAdjacent doesn't consider them to be topologically adjacent. So this problem is more general than sketches: It would happen any time definition.area and definition.vertex are on different bodies.
qContainsPoint(qAdjacent(definition.area, AdjacencyType.VERTEX, EntityType.VERTEX), evaluatedPoint)