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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

ProParameterWithUnitsCreate returning PRO_TK_BAD_INPUTS

MH_10366957
10-Marble

ProParameterWithUnitsCreate returning PRO_TK_BAD_INPUTS

Hello Community,

 

I am using ProParameterWithUnitsCreate, on Creo 9.0.2.0,to add a parameter to a model. However, everything I have tried to make it work has failed. 

 

The code I am using is below:

{

...

ProParamvalueSet(&testVal, p_value, new_value_type);

 

err= ProParameterWithUnitsCreate(&target_item, test, &testVal, NULL, &testInit);

...

}

target_item is a valid ProModelItem, test is a valid wchar_t*, testval is a valid ProParamValue, and testInit is an unitialized ProParameter. I have followed TestParams.c file to check if I did anything wrong, but it appears I have not. 

 

I have also looked at this article, Article - CS383949 - Creo Parametric Toolkit API ProParameterWithUnitsCreate() fails with error PRO_TK_BAD_INPUTS on specific machine (ptc.com), but it is unclear to me what registry file I am supposed to change the unicode_encoding to True on.

 

Does anyone have any idea as to why, with valid inputs, I am receiving the PRO_TK_BAD_INPUTS error?

 

Thanks,

Mark Hardebeck

 

ACCEPTED SOLUTION

Accepted Solutions
RPN
17-Peridot
17-Peridot
(To:MH_10366957)

Check your protk.dat/creotk.dat

ProParameterWithUnitsCreate() fails with error PRO_TK_BAD_INPUTS on specific machine.

Caused by unicode_encoding set to False in the registry file

Resolution: Remove the registry key unicode_encoding (or) set its value to True

 

 

View solution in original post

6 REPLIES 6
RPN
17-Peridot
17-Peridot
(To:MH_10366957)

The model item must have a name, if this is true, you may need to provide more code 😉

MH_10366957
10-Marble
(To:RPN)

TestNewParam(ProMdl target_model){
 
ProError NoConv;
ProModelitem  target_item;
ProParameter testInit ;
ProParamvalue testVal;
ProParamvalueType new_value_type = PRO_PARAM_STRING;
void* p_value;
wchar_t test[120];
char testc[120] = "Param";
 
NoConv = ProMdlToModelitem (target_model,&target_item);
if(NoConv != PRO_TK_NO_ERROR)return(-1);
 
ProStringToWstring(test,testc);

p_value = (void*)(wchar_t*)L"Include params";

ProParamvalueSet(&testVal, p_value, new_value_type);

NoConv = ProParameterWithUnitsCreate(&target_item, test, &testVal, NULL, &testInit);
...
RPN
17-Peridot
17-Peridot
(To:MH_10366957)

This is a simple example from PTC. 

 

ProDrawing drawing;
    ProModelitem model_item;
    ProParamvalue param_value;
    ProParameter parameter;

    status = ProMdlCurrentGet(&drawing);
    status = ProMdlToModelitem(drawing, &model_item);
    param_value.type = PRO_PARAM_DOUBLE;
    param_value.value.d_val = 10.0;
    status = ProParameterWithUnitsCreate(&model_item, L"test", &param_value,NULL, &parameter);

 

 

 

 

 

For a string value use s_val, and copy using ProStringToWstring and PRO_PARAM_STRING for the type. For the Param name, same procedure.

 

Instead of „drawing“ use your ProModel (or Mdl :-))  „model“, same code, makes no different.

 

If this works, check the functions of ProParamvalue* and use them.

 

There are a lot of examples if you have toolkit installed.

MH_10366957
10-Marble
(To:RPN)

I tried using your sample code, but I still received the same PRO_TK_BAD_INPUTS error.

RPN
17-Peridot
17-Peridot
(To:MH_10366957)

Check your protk.dat/creotk.dat

ProParameterWithUnitsCreate() fails with error PRO_TK_BAD_INPUTS on specific machine.

Caused by unicode_encoding set to False in the registry file

Resolution: Remove the registry key unicode_encoding (or) set its value to True

 

 

MH_10366957
10-Marble
(To:RPN)

Ah, thank you, I misunderstood what registry file meant on the solution that PTC provided. That worked for me

Announcements


Top Tags