Skip to main content
1-Visitor
May 20, 2019
Solved

Rotate model using toolkit

  • May 20, 2019
  • 2 replies
  • 3769 views

Hello

 

We would like to rotate model by 90 degree with respect to Y axis. I am using below code :

 

ProError status = PRO_TK_GENERAL_ERROR;

//Get assembly
ProMdl objTopAssembly;
status = ProMdlCurrentGet(&objTopAssembly);

//get current assembly's window
int intWindowID;
status = ProMdlWindowGet(objTopAssembly, &intWindowID);


//Matrix to rotate 90 degree about Y axis
ProMatrix objMatrixAboutY;
objMatrixAboutY[0][0] = cos(1.5707);
objMatrixAboutY[0][1] = 0;
objMatrixAboutY[0][2] = -sin(1.5707);
objMatrixAboutY[0][3] = 0;

objMatrixAboutY[1][0] = 0;
objMatrixAboutY[1][1] = 1;
objMatrixAboutY[1][2] = 0;
objMatrixAboutY[1][3] = 0;

objMatrixAboutY[2][0] = sin(1.5707);
objMatrixAboutY[2][1] = 0;
objMatrixAboutY[2][2] = cos(1.5707);
objMatrixAboutY[2][3] = 0;

objMatrixAboutY[3][0] = 0;
objMatrixAboutY[3][1] = 0;
objMatrixAboutY[3][2] = 0;
objMatrixAboutY[3][3] = 1;

 

// set new matrix
status = ProWindowPanZoomMatrixSet(intWindowID, objMatrixAboutY);

 

//Repaint the window
status = ProWindowRepaint(intWindowID);

 

 

 

This code just rotate the default csys orientation in to creo window. Model is not rotated at all. Am i missing some information? What should be done to rotate model as well?

 

Thanks and Regards

Ketan

Best answer by FV_01

status = ProViewRotate( objTopAssembly, NULL, PRO_Y_ROTATION, 90);		
@Ketan_Lalcheta wrote:

Hello

 

We would like to rotate model by 90 degree with respect to Y axis. I am using below code :

 

ProError status = PRO_TK_GENERAL_ERROR;

//Get assembly
ProMdl objTopAssembly;
status = ProMdlCurrentGet(&objTopAssembly);

//get current assembly's window
int intWindowID;
status = ProMdlWindowGet(objTopAssembly, &intWindowID);


//Matrix to rotate 90 degree about Y axis
ProMatrix objMatrixAboutY;
objMatrixAboutY[0][0] = cos(1.5707);
objMatrixAboutY[0][1] = 0;
objMatrixAboutY[0][2] = -sin(1.5707);
objMatrixAboutY[0][3] = 0;

objMatrixAboutY[1][0] = 0;
objMatrixAboutY[1][1] = 1;
objMatrixAboutY[1][2] = 0;
objMatrixAboutY[1][3] = 0;

objMatrixAboutY[2][0] = sin(1.5707);
objMatrixAboutY[2][1] = 0;
objMatrixAboutY[2][2] = cos(1.5707);
objMatrixAboutY[2][3] = 0;

objMatrixAboutY[3][0] = 0;
objMatrixAboutY[3][1] = 0;
objMatrixAboutY[3][2] = 0;
objMatrixAboutY[3][3] = 1;

 

// set new matrix
status = ProWindowPanZoomMatrixSet(intWindowID, objMatrixAboutY);

 

//Repaint the window
status = ProWindowRepaint(intWindowID);

 

 

 

This code just rotate the default csys orientation in to creo window. Model is not rotated at all. Am i missing some information? What should be done to rotate model as well?

 

Thanks and Regards

Ketan


 

2 replies

14-Alexandrite
May 20, 2019

You should get model transformation matrix and update it than set it.

1-Visitor
May 20, 2019

Yes, but I thought it is required for panning only. 

 

If you refer example given with API, it seems only last row related to panning is required to get transferred with respect to different matrix. Could you please help me with what should be done to give it a try?

 

I know we need to get matrix and got it using ProViewMatrixGet() API. what next? I don't have point to transfer with respect to this matrix. I have 4*4 matrix for rotation about X axis.

1-Visitor
May 20, 2019

I tried below code:

 

ProError status = PRO_TK_GENERAL_ERROR;

//Get assembly
ProMdl objTopAssembly;
status = ProMdlCurrentGet(&objTopAssembly);

//get current assembly's window
int intWindowID;
status = ProMdlWindowGet(objTopAssembly, &intWindowID);

ProMatrix objBaseMatrix;
status = ProViewMatrixGet(objTopAssembly,NULL,objBaseMatrix);

ProPoint3d objLine1 = { cos(1.5707) ,0,-sin(1.5707) };
ProPoint3d objLine2 = { 0 ,1,0 };
ProPoint3d objLine3 = { sin(1.5707) ,0,cos(1.5707) };

status = ProPntTrfEval(objLine1, objBaseMatrix, objLine1);
status = ProPntTrfEval(objLine2, objBaseMatrix, objLine2);
status = ProPntTrfEval(objLine3, objBaseMatrix, objLine3);

//Matrix to rotate 90 degree about Y axis
ProMatrix objMatrixAboutY;
objMatrixAboutY[0][0] = objLine1[0];
objMatrixAboutY[0][1] = objLine1[1];
objMatrixAboutY[0][2] = objLine1[2];
objMatrixAboutY[0][3] = 0;

objMatrixAboutY[1][0] = objLine2[0];
objMatrixAboutY[1][1] = objLine2[1];
objMatrixAboutY[1][2] = objLine2[2];
objMatrixAboutY[1][3] = 0;

objMatrixAboutY[2][0] = objLine3[0];
objMatrixAboutY[2][1] = objLine3[1];
objMatrixAboutY[2][2] = objLine3[2];
objMatrixAboutY[2][3] = 0;

objMatrixAboutY[3][0] = 0;
objMatrixAboutY[3][1] = 0;
objMatrixAboutY[3][2] = 0;
objMatrixAboutY[3][3] = 1;

// set new matrix
status = ProWindowPanZoomMatrixSet(intWindowID, objMatrixAboutY);

//Repaint the window
status = ProWindowRepaint(intWindowID);

 

This at least makes some changes and assembly (not even a single portion) is not visible at all in window. But I was expecting assembly to be rotated by 90 degree w.r.t. Axis.

 

Any idea would be of great help.

FV_0117-PeridotAnswer
May 20, 2019

status = ProViewRotate( objTopAssembly, NULL, PRO_Y_ROTATION, 90);		
@Ketan_Lalcheta wrote:

Hello

 

We would like to rotate model by 90 degree with respect to Y axis. I am using below code :

 

ProError status = PRO_TK_GENERAL_ERROR;

//Get assembly
ProMdl objTopAssembly;
status = ProMdlCurrentGet(&objTopAssembly);

//get current assembly's window
int intWindowID;
status = ProMdlWindowGet(objTopAssembly, &intWindowID);


//Matrix to rotate 90 degree about Y axis
ProMatrix objMatrixAboutY;
objMatrixAboutY[0][0] = cos(1.5707);
objMatrixAboutY[0][1] = 0;
objMatrixAboutY[0][2] = -sin(1.5707);
objMatrixAboutY[0][3] = 0;

objMatrixAboutY[1][0] = 0;
objMatrixAboutY[1][1] = 1;
objMatrixAboutY[1][2] = 0;
objMatrixAboutY[1][3] = 0;

objMatrixAboutY[2][0] = sin(1.5707);
objMatrixAboutY[2][1] = 0;
objMatrixAboutY[2][2] = cos(1.5707);
objMatrixAboutY[2][3] = 0;

objMatrixAboutY[3][0] = 0;
objMatrixAboutY[3][1] = 0;
objMatrixAboutY[3][2] = 0;
objMatrixAboutY[3][3] = 1;

 

// set new matrix
status = ProWindowPanZoomMatrixSet(intWindowID, objMatrixAboutY);

 

//Repaint the window
status = ProWindowRepaint(intWindowID);

 

 

 

This code just rotate the default csys orientation in to creo window. Model is not rotated at all. Am i missing some information? What should be done to rotate model as well?

 

Thanks and Regards

Ketan