selection edge stops at first type encountered

Hello,

I am trying to select one edge on a surface. It works pretty good on a simple cube. I use selectById2 function and my xyz coordinates are correct.

When I have another extrusion next to the surface, making a 90 degrees angle, then if you put the left view for example, the edge you want to select will be aligned with the one of the extrusion and it will select the first edge found instead of the one behind and even if my xyz coordinates are good. Same mistake if you try to select by using a top view, it will not select the edge I want but the first one encountered.

Does it exist such a solution to be able to go through an object and reaches the real coordinates given ? 

Thanks

Vincent 

SolidworksApi/macros