Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

How to reset parameter value -Pro/Toolkit

rnd_doss

New member
Hi folks,


I need to understand better how to set parameter value for existing parameter. Assume that there is partnamely "123456"is available in current session, the same part having the paramater "PART_NO" and the value is "123456". Now i am going to rename the part getting input from user. So now i have a model handle with part name. I want to set the same value for "PART_NO" parameter. Can you please some one suggest the better to accomplish this one.


Thanks.
 
Will the rename be taking place while your program is running? If so - just have it set the parameter to the same name. If you want the parameter to always be named what the model name is whether they're running your program or not then just set up a notification event for a post rename that changes the parameter.
 
Hi Bryan, thanks for your update.


Yes, rename takes place while my program is running. As well my parameter depends the current file(part) name. whenever if user reaname the part, then parameter also need to change. I have a bit confusion setting parameter value after rename. can you please explain me the set of instructions to set the parameter value.


Thanks.
 
Check out the function ProParameterValueSet in the documentation. There are some examples in there. Basically you just do this if you have the model handle and know the parameter name already:

  1. <LI>Cast your model to a model item usingProMdlToModelitem.
    <LI>Initializethe data structureusing the name and the modelitem handle from step 1 usingProParameterInit.
    <LI>Use ProParamvalueSet with the structure from step 2 to set thevalue to what you want. I assume you'd want type PRO_PARAM_STRING since it follows the model name.
    <LI>Send that back to the model using ProParameterValueSet.</LI>


Try that out and if you get stuck I can probably put together a quick working sample for you.
Edited by: bruppert
 
Hi Bryan,


My code is here,


======================================================


ProName name, cp_name, wp_name;
ProMdl model;
ProModelitem mdl_item;
ProError status;
ProParameter param;


ProStringToWstring (name, "PART_NO");


status = ProMdlCurrentGet (&model);

status = ProMdlNameGet( model, cp_name );


ProWstringToString (wp_name, cp_name );


status = ProMdlToModelitem (model, &mdl_item);

status = ProParameterInit(&mdl_item, name, &param);


status = ProParamvalueSet( &param, wp_name[PRO_NAME_SIZE], PRO_PARAM_STRING );


======================================================


While compiling this code, i am gettingthe warning...


warning C4133: 'function' : incompatible types - from 'unsigned short [32]' to


warning C4133: 'function' : incompatible types - from 'struct proparameter *'


for line "ProWstringToString (wp_name, cp_name )" and "status = ProParamvalueSet( &param, wp_name[PRO_NAME_SIZE], PRO_PARAM_STRING );" respectively.


In addition, proe exists while running this code. Can you please suggest the modification.


Thanks
 
Here's my modifications to your code plus comments. Good luck!


ProName name, cp_name, wp_name;
ProMdl model;
ProModelitem mdl_item;
ProError status;
ProParameter param;
ProParamvalue paramValue;


ProStringToWstring(name, "PART_NO");


status = ProMdlCurrentGet (&model);


status = ProMdlNameGet( model, cp_name );


//Don't need next line - cp_name is already a ProName and you declared wp_name as ProName, that's why you were getting the firsterror


// ProWstringToString(wp_name, cp_name );


status = ProMdlToModelitem (model, &mdl_item);


status = ProParameterInit(&mdl_item, name, &param);


// You need to get the value that you're going to set since ProParamvalueSet wants a ProParamvalue so add this line:


status=ProParameterValueGet(&param, &paramValue);


// Use the ProParamValue from above, not ProParameter like you had, and you might as well just use cp_name since it's the value you want anyways. Plus don't send in with [PRO_NAME_SIZE] because it expects a wchar_t*


status = ProParamvalueSet(&paramValue, cp_name, PRO_PARAM_STRING );


// All the above stuff just set the structure up, now you need to send it back to the model so do this:


status=ProParameterValueSet(&param, &paramValue);



Edit note: cp_name will have the .prt extension on it. You could use ProMdlDataGet and then just use the ".name" slot for the basename like this:


ProMdldata data;


status=ProMdlDataGet(model, &data);



// Then use data.name in ProParamvalueSet instead of cp_name
Edited by: bruppert
 
Hi Bryan,


Thanks for your prompt response. Finally i succeed with the code that you modified. I have been modified by using ProMdlDataget to get the current drawing. Once again thanks for your valuable support.


Thanks.
 

Sponsor

Back
Top