Skip to main content
10-Marble
March 17, 2023
Solved

How to calculate the position of the mouse pick on the model .

  • March 17, 2023
  • 1 reply
  • 1787 views

Hello everyone!

I want to calculate the coordinates of the mouse left click point on the solid model.

So I tried the following, but the calculation is wrong.

 

pfcSession_ptr mysess = pfcGetProESession();
pfcMouseStatus_ptr MouseStatus = mysess->UIGetNextMousePick(pfcMOUSE_BTN_LEFT);
pfcPoint3D_ptr Position = MouseStatus->GetPosition();
pfcView_ptr view = mysess->GetCurrentModel()->GetCurrentView();
pfcTransform3D_ptr Transform3D = view->GetTransform();
Transform3D->Invert();
pfcPoint3D_ptr model_point = Transform3D->TransformPoint(Position);

 

The “model_point” is wrong .

And I can't select points through the function "pfcBaseSession::select()", because there are no points on the surface, I want to calculate the position of the mouse click on the point position on the surface of the solid model.

Can anyone tell me how to do it, or is there any other way,thanka!

 

 

Best answer by RPN

I guess you get only the screen coordinates, no z value.

 

in Toolkit I would use this:

extern ProError ProSelectionPoint3dGet( ProSelection selection,
					ProPoint3d point );
/*
 Purpose: Retrieves the coordinates of the selected point in the member 
 coordinate system.

 Input Arguments:
 selection - The selection object

 Output Arguments:
 point - The point coordinates 

 Return Values:
 PRO_TK_NO_ERROR - The function successfully retrieved the information.
 PRO_TK_BAD_INPUTS - The selection or depth is NULL.
 PRO_TK_INVALID_PTR - The selection argument is an invalid pointer.
*/

 My assumption is, this will return a point on the surface, if your type Is “surface”

 

 

1 reply

10-Marble
March 17, 2023

Use this function to get the point position.

NT_10507751_0-1679043099553.png

 

RPN
RPN18-OpalAnswer
18-Opal
March 19, 2023

I guess you get only the screen coordinates, no z value.

 

in Toolkit I would use this:

extern ProError ProSelectionPoint3dGet( ProSelection selection,
					ProPoint3d point );
/*
 Purpose: Retrieves the coordinates of the selected point in the member 
 coordinate system.

 Input Arguments:
 selection - The selection object

 Output Arguments:
 point - The point coordinates 

 Return Values:
 PRO_TK_NO_ERROR - The function successfully retrieved the information.
 PRO_TK_BAD_INPUTS - The selection or depth is NULL.
 PRO_TK_INVALID_PTR - The selection argument is an invalid pointer.
*/

 My assumption is, this will return a point on the surface, if your type Is “surface”

 

 

10-Marble
March 29, 2023

yes, thank you!