Handle Operator Position

We would like to implement the handle operator functionality that’s within the demo where you can right click on the model tree and ‘Show Handles’ on a given part - What I can’t figure out is how you determine the center point of the part. Per the selection manager you can determine position of everything but a part, how can you derive the position to properly place the handles?

Thanks,
Justin

Hello @justin.larosa,

When you activate the handle operator through the model browser, the position of handle operator is the center of the bounding box of the node (or nodes). You can try something like:

let nodeIds = [myNode]; //supply your node (or nodes) 
let boundingBox = await hwv.model.getNodesBounding(nodeIds);
                			
let om = hwv.operatorManager;
let operatorHandle = om.getOperator(Communicator.OperatorId.Handle);
operatorHandle.addHandles(nodeIds, boundingBox.center());

For the function addHandles, the position parameter is optional and calling the function without it will place the handles at the bounding box center by default.

Also, as a reference, the TypeScript for the handle operator is included in the Communicator package and can be found in:
HOOPS_Communicator_2024.X.x\web_viewer\deprecated\typescript\operators\HandleOperator.ts

Thanks,
Tino

1 Like

Thank you @tino that worked for us.

1 Like