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.

Consistent normals for cirlces

billyzelsnackbillyzelsnack Member Posts: 56 ✭✭
I have a feature that lets me click on a bunch of circles within a part studio and it creates additional parts at those circles. It works but the normals for the circles are flipped inconsistently if I gather them from circle.coordSystem. I'd like to gather them from their sketchplanes but I'm getting a CANNOT_RESOLVE_PLANE.

Here's the simplified precondition..

annotation { "Name" : "Choose circle edges", "Filter" : EntityType.EDGE && GeometryType.CIRCLE }
definition.circleEdges is Query;

Here's the simplification of how I iterate over the circles..

const circleEdges=evaluateQuery(context, definition.circleEdges );
for (var circleEdge in circleEdges){ const plane=evOwnerSketchPlane(context, { "entity" : circleEdge }); }

I'm not understanding why I can't resolve the plane. The cirlceEdge is an entity isn't it?



Best Answers

  • lanalana Posts: 490
    Accepted Answer
    @billyzelsnack
    Is  evPlane(context, {"face" : qEdgeAdjacent(circleEdge, EntityType.FACE)})   giving you the expected result?
    It will work only if circular edge is adjacent to a plane, though. Is this a requirement for your feature input.

Answers

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 455
    Your code looks good. Yes, circleEdge should be a query for a single entity. Assuming that entity is from a sketch, everything should resolve.

    I just tried and this works for me: https://cad.onshape.com/documents/6da56483710c2b0b2ed1a40b/w/b27042b1cc6a6646c7430d2c/e/f0ab954db4f46bc6e628f248

    Is it possible you're using edges that aren't coming from sketches?

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 941 ✭✭✭✭✭
    edited April 2017
    are you supposed to select only sketch geometry for the circle edges - then add to filter
    SketchObject.YES
    if not  - you would better use for plane definition
    plane(evAxis(circleEdge).origin,evAxis(circleEdge).normal)




  • billyzelsnackbillyzelsnack Member Posts: 56 ✭✭

    Is it possible you're using edges that aren't coming from sketches?
    Hmm. That's probably the issue. I was thinking about the problem entirely wrong and the sketchplane is not going to give me what I want.


    How would I go about getting the outward facing normals in this example..

    A rectangle with a circle inside it is extruded to create a box with a hole all the way through it. As in your example I would like to select both circles on opposite sides of the box. As it is now I can iterate over each circle and get a coordSystem from each. However the coordSystem normal is the same for both circles rather than pointing in opposite direction..

    const circleEdges=evaluateQuery(context, definition.circleEdges );
    for (var circleEdge in circleEdges)
    {            
        const circle is Circle = evCurveDefinition(context, { "edge" : circleEdge });   

    circle.coordSystem gives me everything I need except the normal might be flipped. How would I get a consistent outward facing normal?

    }


  • billyzelsnackbillyzelsnack Member Posts: 56 ✭✭
    are you supposed to select only sketch geometry for the circle edges - then add to filter
    SketchObject.YES
    if not  - you would better use for plane definition
    plane(evAxis(circleEdge).origin,evAxis(circleEdge).normal)




    var aline=evAxis(context,{"axis":circleEdge});
    var aplane=plane(aline.origin,aline.direction);

    This is giving me the same inconsistent normals as asking via evCurveDefinition(context, { "edge" : circleEdge }).coordSystem.


  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 941 ✭✭✭✭✭
    @billyzelsnack what is your criteria for correct normal direction? should the normal have a positive projection at some vector?
    i'm afraid we couldn't solve the problem untill find some formal criteria
  • lanalana Onshape Employees Posts: 490
    Accepted Answer
    @billyzelsnack
    Is  evPlane(context, {"face" : qEdgeAdjacent(circleEdge, EntityType.FACE)})   giving you the expected result?
    It will work only if circular edge is adjacent to a plane, though. Is this a requirement for your feature input.

  • billy2billy2 Member, OS Professional, Mentor, Developers Posts: 1,325 PRO
    edited April 2017
    Circles have direction, it's the plane's normal. Circle's always have planes. The plane comes 1st in a circle's definition. 

    If you use a body to create the sketch, then the sketch normal is always away from the body. A cut from a circle on a sketch should have a consistent normal based on the face chosen for the sketch which should be away from the bodies center of mass. Shiny side out is positive. This will dictate the circle's normal.

    If you need to make a decision, take the dot product relative to the front plane's Z direction or 0,0,1 world coordinates. 

    Of course, there's always the possibility that I have no idea what you guys are talking about.


    for clarity's sake, circle normal is Z world:


    Edge normal should be Z world:



    On the underside, is this edge based on the adjacent faces or the sketch circle's normal:


    I don't know if that edge knows about the sketch.

    I would predict that this edge would be the anti-normal 0, 0, -1.

    If this geometry came in from parasolids and had no sketches, the 2 faces are analytic and could derive a circle definition. My guess would be the circle is anti-normal relative to the world.


    Let me know if you figure it out.


  • billyzelsnackbillyzelsnack Member Posts: 56 ✭✭
    edited April 2017
    @lana
    It returns the normal I'm looking for with the center of the face but combined with the other information I have I think I have what I need to make it work. Thanks.

  • billy2billy2 Member, OS Professional, Mentor, Developers Posts: 1,325 PRO
    Ok, thanks.

    The edge is the intersect of a plane face & cyl face, it's normal is based on the planar face and is shiny side out.

    good to know,



  • billyzelsnackbillyzelsnack Member Posts: 56 ✭✭
    I've run into an error with evPlane that I do not understand.

    Here's a simplified example.
    https://cad.onshape.com/documents/58fa73288614a7114f1a299c/w/00d15f89472e5b3b9afecce9/e/7aaeb3191d24d17729b7c39f

    It works for the circles on Extrude1 and Extrude3, but not for Extrude2.






  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 941 ✭✭✭✭✭
    instead of qOwnedByBody you need qOwnerBody in mate connector owner

  • billyzelsnackbillyzelsnack Member Posts: 56 ✭✭
    @konstantin_shiriazdanov
    I was under the impression that sharing a link would share the specific version it was at when I shared it. I guess you looked at it while I was messing with it. If you look at it how it is now there are debug statements in there to show the planes and I've commented out the mate connector op. However you'll need to edit the feature for the planes to show up.
  • billyzelsnackbillyzelsnack Member Posts: 56 ✭✭
    I think I figured out the the issue.

    V3 here.. https://cad.onshape.com/documents/58fa73288614a7114f1a299c/w/00d15f89472e5b3b9afecce9/e/7aaeb3191d24d17729b7c39f

    qEdgeAdjacent can return multiple faces and I was just getting lucky with ordering. Depending on the ordering evPlane would try to find the plane for a cylinder face and that's not going to work.




  • billyzelsnackbillyzelsnack Member Posts: 56 ✭✭

    Thanks @lana . I've updated the minimal example. Much cleaner now.
Sign In or Register to comment.