cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

How to Use Creo ToolKit Function "ProExpldstateMovesSet()"

timy
8-Gravel

How to Use Creo ToolKit Function "ProExpldstateMovesSet()"

Hi All,

As title, I have already given parameters including below

---

p_move_arr.comp_set=&asm_prt_data[i].comp_path;
p_move_arr.move.value=300;
p_move_arr.move.move_type=PRO_EXPLDANIM_MOVE_TRANSLATE;

p_move_arr.move.direction.dir_vector[0]=0

p_move_arr.move.direction.dir_vector[1]=1

p_move_arr.move.direction.dir_vector[2]=0

for(int start_p=0;start_p<3;start_p++)
{
p_move_arr.move.direction.start_point[start_p]=0;
}

err=ProExpldstateMovesSet(&exp_hand,&p_move_arr);

------

But the component  dosent  move  in my creo3.0

is there any problems in my program?

1 ACCEPTED SOLUTION

Accepted Solutions
FV
17-Peridot
17-Peridot
(To:timy)

edited, please check for spelling errors

 

/* //somewhere in calling function
{
ProAsmcomppath *cpath_arr = NULL;
ProArrayAlloc( 0, sizeof(ProAsmcomppath), 1, (ProArray*) &cpath_arr);
ProArrayObjectAdd( (ProArray*) &cpath_arr, PRO_VALUE_UNUSED, 1, (void*) &cpath1);
ProArrayObjectAdd( (ProArray*) &cpath_arr, PRO_VALUE_UNUSED, 1, (void*) &cpath2);
ProArrayObjectAdd( (ProArray*) &cpath_arr, PRO_VALUE_UNUSED, 1, (void*) &cpath3);
...

}
*/



ProError err = PRO_TK_GENERAL_ERROR;
ProVector trans_vecZ = {0.0, 0.0, 1.0};
ProVector trans_vecX = {1.0, 0.0, 0.0}; ProExpldAnimMoveData *moves_arr = NULL;
err=ProArrayAlloc(0, sizeof(ProExpldAnimMoveData), 1, (ProArray *)&moves_arr);
//repeat as needed
{
//all of it has to called AFTER moves_arr allocated
ProExpldAnimMoveData move_dataZ;
ProExpldAnimMoveData move_dataX;
err=ProExpldAnimDataTranslatemoveInit(trans_vecZ,cpath_arr, &move_dataZ);
err=ProArrayObjectAdd((ProArray*)&moves_arr,PRO_VALUE_UNUSED,1,(void*)&move_dataZ);
err=ProExpldAnimDataTranslatemoveInit(trans_vecX,cpath_arr, &move_dataX);
err=ProArrayObjectAdd((ProArray*)&moves_arr,PRO_VALUE_UNUSED,1,(void*)&move_dataX);

}

{
ProName expName = L"TEST";
ProExpldstate expl_state; err=ProExpldstateCreate((ProSolid)asm_mdl,expName,NULL,&expl_state); err=ProExpldstateMovesSet(&expl_state,moves_arr); err=ProExpldanimmovedataProarrayFree(moves_arr);
err=ProExpldstateActivate((ProSolid)asm_mdl,&expl_state);
}

err=ProAssemblyExplode((ProAssembly)asm_mdl); err=ProWindowRepaint(-1);



 


 

View solution in original post

8 REPLIES 8
timy
8-Gravel
(To:timy)

Is there anyone can help me ~~

FV
17-Peridot
17-Peridot
(To:timy)

Hello,

p_move_arr in your code is used as struct. This is wrong. You should be using ProExpldAnimDataTranslatemoveInit and adding the initiated object to a ProArray of 'ExpldStateMoves'.

An explode state itself should be either created or initiated and after moves were set should be activated with ProExpldstateActivate(..) and finally ProAssemblyExplode(...)  should be called to display an exploded assembly.

FV. 

timy
8-Gravel
(To:FV)

Hi @FV,

below are my code

---

ProName expName;
ProExpldstate exp_hand;
VecCopy(trans_vec,Vec_Carray_resonable[0].vec_resonable);        //assign vector to trans_vec


err=ProExpldAnimDataTranslatemoveInit(trans_vec,&asm_prt_data[i].comp_path,&move_data);

***the function will output "PRO_TK_BAD_INPUTS", if I dont give ProArray of compont.

(Here is a question, if i dont give a specific compnent, How do i know which component I could control? )


move_data.move.value=30;
ProStringToWstring(expName,"Demo");
err=ProExpldstateCreate((ProSolid)asm_mdl,expName,&move_data,&exp_hand);
err=ProExpldstateInit(expName,NULL,(ProSolid)asm_mdl,&exp_hand);
err=ProExpldstateActivate((ProSolid)asm_mdl,&exp_hand);
err=ProAssemblyExplode((ProAssembly)asm_mdl);

---

Could you please give me an example to demonstrate how to do it?

BTW

If I assigned &asm_prt_data->comp_path, The function will output PRO_TK_NO_ERROR, but the explode result still shows nothing.

FV
17-Peridot
17-Peridot
(To:timy)

LIB_COREUTILS_API  ProError ProExpldAnimDataTranslatemoveInit (ProVector            trans_vec, 
                                                   ProAsmcomppath       *comp_set, 
                                                   ProExpldAnimMoveData *p_move_data);
/*
   Purpose:  Creats a translational move.

   Input Arguments:
      trans_vec            - The direction of the translation. Cannot be NULL.
      comp_set             - ProArray of components to which this move will be applied.
                             cannot be NULL or empty.
   Output Arguments:
      p_move_data          - The move. Cannot be NULL.

   Return Values:
      PRO_TK_NO_ERROR      - The move is created successfully.
      PRO_TK_BAD_INPUTS    - Some arguments are invalid.

you are using : err=ProExpldAnimDataTranslatemoveInit(trans_vec,&asm_prt_data[i].comp_path,&move_data);

 

look at the function definition above - the second argument (comp_set) is ProArray of ProAsmcomppath

 

You are also missing using function ProExpldstateMovesSet - how does your exploded state know what moves to use?

Also you are not adding the initiated move_data to moves array...

 

what you should be doing is:

-initiate ProArray of ProExpldAnimMovedata

- initiate ProArray of ProAsmcomppath

- build ProArray of ProAsmcomppath - components to be moved in exploded view

- initiate ProExpldAnimMovedata struct

- add this struct to ProArray of movedatas, repeat those two steps as necessary

- create exploded state with ProExpldstateCreate, use NULL for move_data argument

- add movedatas ProArray to the exploded state with ProExpldstateMovesSet

- release movedata ProArray with ProExpldanimmovedataProarrayFree

- activate exploded state with ProExpldstateActivate

- finally ProAssemblyExplode

 

timy
8-Gravel
(To:FV)

hmmm, quite  a difficult topic.

timy
8-Gravel
(To:FV)

 

ProVector trans_vec;
ProName expName;
ProExpldAnimMoveData *p_move_data,move_data;
ProExpldstate p_new_expl_state;

ProStringToWstring(expName,"Test");
VecCopy(trans_vec,Vec_Carray_resonable[0].vec_resonable);
err=ProExpldAnimDataTranslatemoveInit(trans_vec,&asm_prt_data->comp_path,&move_data); err=ProArrayAlloc(0, sizeof(ProExpldAnimMoveData), 1, (ProArray *)&p_move_data); err=ProArrayObjectAdd((ProArray*)&p_move_data,PRO_VALUE_UNUSED,1,&move_data); err=ProExpldstateCreate((ProSolid)asm_mdl,expName,NULL,&p_new_expl_state); err=ProExpldstateMovesSet(&p_new_expl_state,p_move_data); err=ProExpldanimmovedataProarrayFree(p_move_data); err=ProExpldstateActivate((ProSolid)asm_mdl,&p_new_expl_state); err=ProAssemblyExplode((ProAssembly)asm_mdl); err=ProWindowRepaint(-1);

Hi @FV,

Above is my Explode code.

I am not sure about building ProArray of movement, cause it will shut down at ProExpldstateMovesSet

Is there any wrong in my code?

 

FV
17-Peridot
17-Peridot
(To:timy)

edited, please check for spelling errors

 

/* //somewhere in calling function
{
ProAsmcomppath *cpath_arr = NULL;
ProArrayAlloc( 0, sizeof(ProAsmcomppath), 1, (ProArray*) &cpath_arr);
ProArrayObjectAdd( (ProArray*) &cpath_arr, PRO_VALUE_UNUSED, 1, (void*) &cpath1);
ProArrayObjectAdd( (ProArray*) &cpath_arr, PRO_VALUE_UNUSED, 1, (void*) &cpath2);
ProArrayObjectAdd( (ProArray*) &cpath_arr, PRO_VALUE_UNUSED, 1, (void*) &cpath3);
...

}
*/



ProError err = PRO_TK_GENERAL_ERROR;
ProVector trans_vecZ = {0.0, 0.0, 1.0};
ProVector trans_vecX = {1.0, 0.0, 0.0}; ProExpldAnimMoveData *moves_arr = NULL;
err=ProArrayAlloc(0, sizeof(ProExpldAnimMoveData), 1, (ProArray *)&moves_arr);
//repeat as needed
{
//all of it has to called AFTER moves_arr allocated
ProExpldAnimMoveData move_dataZ;
ProExpldAnimMoveData move_dataX;
err=ProExpldAnimDataTranslatemoveInit(trans_vecZ,cpath_arr, &move_dataZ);
err=ProArrayObjectAdd((ProArray*)&moves_arr,PRO_VALUE_UNUSED,1,(void*)&move_dataZ);
err=ProExpldAnimDataTranslatemoveInit(trans_vecX,cpath_arr, &move_dataX);
err=ProArrayObjectAdd((ProArray*)&moves_arr,PRO_VALUE_UNUSED,1,(void*)&move_dataX);

}

{
ProName expName = L"TEST";
ProExpldstate expl_state; err=ProExpldstateCreate((ProSolid)asm_mdl,expName,NULL,&expl_state); err=ProExpldstateMovesSet(&expl_state,moves_arr); err=ProExpldanimmovedataProarrayFree(moves_arr);
err=ProExpldstateActivate((ProSolid)asm_mdl,&expl_state);
}

err=ProAssemblyExplode((ProAssembly)asm_mdl); err=ProWindowRepaint(-1);



 


 

timy
8-Gravel
(To:FV)

Hi @FV,

 I appreciate your kind assistance!!!!

Top Tags