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.

Options

Get vector for edge direction

DSPuzzlesDSPuzzles Member Posts: 17 EDU
I am writing a feature that requires me to select a vertex and returns the vectors corresponding to the direction of the edges that meet at that vertex. Is this possible?

Thank you.
Tagged:

Comments

  • Options
    lemon1324lemon1324 Member, Developers Posts: 223 EDU
    edited August 2017
    Yeah, should be pretty straightforward.  Head to the documentation and check out the qVertexAdjacent and evEdgeTangentLine functions.
    Arul Suresh
    PhD, Mechanical Engineering, Stanford University
  • Options
    kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited August 2017
    Definitely! I made a public doc as an example:
    https://cad.onshape.com/documents/71cf88a8c2e0951f0f60de72/w/8c5180c50706c37a3c028753/e/eb84571c61056de69feff247


    The underlying functions here are qVertexAdjacent and evEdgeTangentLine.

    Let us know if you have more questions!
  • Options
    DSPuzzlesDSPuzzles Member Posts: 17 EDU
    Thank you very much!

    A follow-up question for the same feature, how do I specify in a query for vertices that I want to allow the selection of midpoints of edges? Whenever I use "Filter: EntityType.VERTEX" I can never select these, while in OnShape features like the transform tool in translation mode I am able to select these points. I've looked through the source code but cannot seem to find a reason for these
  • Options
    Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646
    Hello!

    For various development reasons edge points (our internal name for edge midpoints) are only created if edges are selectable into the box in question.  The filter "Filter: EntityType.VERTEX || EntityType.EDGE" will allow you to select those edge points that you want to get at.  It will also allow you to select edges, which may not be desirable for your feature.  The following code may be helpful:
    if (size(evaluateQuery(context, qEntityFilter(definition.point, EntityType.EDGE))) > 0)
        throw "Feature does not support edge selections, select vertex or midpoint";

    This bug is on our radar, but you can help by clicking "report a bug" from the "?" menu in your Part Studio.

    Hope this helps!
    Jake Rosenfeld - Modeling Team
Sign In or Register to comment.