Issue with Multi-selection object transformation

Hello everyone,

I'm facing an issue with selecting and translating multiple parts in my application built using OpenCascade. Here's the scenario:

Condition 1

I first select Part_A, then select Part_B.

Now both parts appear selected.

When I apply a translation along any axis, only one part moves, the other stays in place.

Condition 2

I first select Part_B, then select Part_A.

Again, both parts appear selected.

When I apply a translation, both parts move together, as expected.

Problem
The behavior is inconsistent. Depending on the order of selection, sometimes one part moves and sometimes both move. Even worse, this behavior changes randomly between different builds of the application, without any changes to the selection code.

My Code
Here's the relevant code snippet for selection and transformation:


gp_pnt firstPoint = 0,0,0;
gp_pnt secondPoint = 0,90,0;


forEach(part in AIS_InteractiveObjectList){
gp_Trsf tempTrnsf = part->LocalTransformation();
tempTrnsf.SetTranslation(gp_Pnt(0, 0, 0), gp_Pnt(0, 90, 0));
part->SetLocalTransformation(tempTrnsf);
}
Context->UpdateCurrentViewer();

gkv311 n's picture

It is expected to use method AIS_InteractiveContext::SetLocation() instead of direct call to SetLocalTransformation() for displayed object to make updates on selection manager and in highlight.

Apart from this, it is unclear what might go wrong without a reproducer...

rahulmulik9's picture

This approach also didn’t work as expected.
Here are my observations while trying different solutions:

Initially, I was saving the selected objects into a separate list and then accessing them from that list to apply the transformation.
This led to the issue.

However, when I directly retrieved the selected objects from the interactive context and applied the same transformation within the loop, the issue no longer occurred.

I’m not entirely sure about the root cause, but this change has resolved the issue for now.