evCollision doesn't seem to work

christopher_dziuba
christopher_dziuba Member Posts: 125 ✭✭✭

I can't get all 8 "Clash type" results when clashing solid bodies. Here's what I can get:
INTERFERE = Volumes and faces are intersecting
ABUT_NO_CLASS = only faces are intersecting
TOOL_IN_TARGET = only volumes intersect tool contained
TARGET_IN_TOOL = only volumes intersect target contained
NONE = ????????

EXISTS = ????????

ABUT_TOOL_IN_TARGET = ????????
ABUT_TOOL_OUT_TARGET = ????????

image.png

annotation { "Feature Type Name" : "Collision Type Testing", "Feature Type Description" : "" }
export const collision = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{annotation { "Name" : "Tools", "Filter" : EntityType.BODY&&BodyType.SOLID}
definition.tools is Query;    
annotation { "Name" : "Targets", "Filter" : EntityType.BODY&&BodyType.SOLID}
    definition.targets is Query;
}
{
    var tools = definition.tools;
    var targets = definition.targets;
    for(var i=0;i<8;i+=1)
    {
        var collisionArray = evCollision(context, {
                "tools" : qNthElement(tools, i),
                "targets" : qNthElement(targets, i)
        });
        
        print("Collision("~i~")-");
        for(var collision in collisionArray)
        {
            print(collision["type"]~",");
        }
        println();
    }
});

gets us this result:
Collision(0)-
Collision(1)-INTERFERE….
Collision(2)-ABUT_NO_CLASS…..
Collision(3)-ABUT_NO_CLASS…..
Collision(4)-ABUT_NO_CLASS…..
Collision(5)-INTERFERE…..
Collision(6)-TARGET_IN_TOOL
Collision(7)-TOOL_IN_TARGET

I was expecting:
Collision(0)-NONE
Collision(1)-INTERFERE
Collision(2)-EXISTS
Collision(3)-ABUT_NO_CLASS
Collision(4)-ABUT_TOOL_OUT_TARGET
Collision(5)-ABUT_TOOL_IN_TARGET
Collision(6)-TARGET_IN_TOOL
Collision(7)-TOOL_IN_TARGET

Why was I wrong?

Feature Studio
part Studio

Tagged:

Comments

  • jnewth_onshape
    jnewth_onshape Member, Onshape Employees Posts: 89 image
    edited October 2024

    Hi there! You're right, evCollision is quite tricky to use correctly and our documentation is a bit limited. I have filed a documentation bug for evCollision. In the meantime:

    Your testbed is very elegant but doesn't cover all of the possible topological types.
    EXISTS: In Onshape we have several things you might think of as "edges" (edge of a body, line in a sketch, curve) but under the hood these aren't all the same. Sometimes we create what's called a "wire body" to represent an edge. A wire body is a body but it has only 1 dimension.

    You can "get to" the body specified by a sketch edge (through filtering) or creating curves and select them.

    For collisions between two 1-dimensional bodies, does containment mean anything? Does abutment? (They don't, but it took me a bit to think through this). Because these concepts don't mean anything, we the parasolid kernel just returns EXISTS. Here's a screen showing the result of an evCollision between two curves:

    Greenshot 2024-10-04 12.52.36.png

    https://cad.onshape.com/documents/fbaa3ed3488b3b8ae9e43279/w/b46702da3570a73396c3c9bf/e/627d935caa91d9fa77435469

  • christopher_dziuba
    christopher_dziuba Member Posts: 125 ✭✭✭

    @jnewth_onshape amazing sir thank you for the follow up :D ! this has been bugging me for a while