paullee wrote: ↑
Fri Mar 02, 2018 9:47 am
Anyway, if (so far) there is no way to identify the edge selected (shape) outside Edit Mode in the Edit Mode, then need to let the user to enter in edit mode to do the selection...
Yeah, I wrote that functionality into my workbench, but if all you're doing is entering edit mode just to get references to selected geometry, it's definitely undesirable...
Regarding your original post:
paullee wrote: ↑
Fri Mar 02, 2018 12:15 am
Edges nos. BECOME (report here as it is in same direction) 1-(none)-3-2.
Or ClockWire as 1-2-3
So what appears to be happening is elements at the end of the list appear to be getting reordered to fill in the spots for the "missing" construction geometry higher up. I don't know if that's consistently how it works, but even if it does, trying to anticipate that reordering would be prohibitively difficult.
I have one idea that should work, but it's not pretty.
The SelectionObject.PickedPoints attribute returns a vector list of selected vertices. If you have no vertices selected, but only edges, then PickedPoints returns a point on that selected edge (how it's computed, I'm not sure). You *could* iterate through the geometry list and compute the equation of the line for each Part.LineSegment, then test to see if the PickedPoints vector falls on that line. If so, then that's your selection.
The same is true for arcs. The solution is a bit more involved, though, as it would mean doing two things: First, calculate the arc paramter() value using the PickedPoints vector, then check to ensure it falls between the arc's FirstParameter and LastParameter attributes. Second, compute the distance between the PickedPoints vector and the arc's center, and test to see if it matches the radius. If both conditions are met, that's your selection. Note that floating point error applies, here - your tests for equality will have to allow for a small tolerance.
It's a really ugly, brute-force solution, but that's the only way i can see how you could correlate the Shape geometry with the underlying Coin3D geometry outside edit mode.
Also, I've developed my own Python classes to handle stuff like this. It's a bit complicated, but in the end, it makes the problem much easier to manage. I'm not doing what you're doing, but I know what I've written would adapt well to solving this problem. If you're interested, I can post something later about that. Otherwise, you'll have to auto-enter Edit mode and manage selection that way.
I might also suggest putting in a feature request with the devs for a more consistent coupling between the Coin3D geometry and the Shape geometry so we can more reliably correlate selections in Sketcher. I don't know if it's a reasonable thing to ask for, but it can't hurt to try.