Hi,
Here's another piece of code for that purpose, used to copy/create
parameters from model to drawing.
// Use the current drawing.
status = ProMdlCurrentGet ((ProMdl*)&drawing);
if (status != PRO_TK_NO_ERROR)
return (status);
// Get the drawings current/active model.
status = ProDrawingCurrentsolidGet ((ProMdl)drawing, &solid);
if (status != PRO_TK_NO_ERROR)
return (status);
// Set parameter type and value.
for(i=0; i<7; i++)
{
if(i == 0) ProStringToWstring(name, "DESCRIPTION");
if(i == 1) ProStringToWstring(name, "NUMBER");
if(i == 2) ProStringToWstring(name, "RESPONSIBLE_DEPARTMENT");
if(i == 3) ProStringToWstring(name, "TAKE_OVER_DEPARTMENT");
if(i == 4) ProStringToWstring(name, "PRODUCTTYPE");
if(i == 5) ProStringToWstring(name, "PROJECTID");
if(i == 6) ProStringToWstring(name, "REVISIONTEXT");
value.type = PRO_PARAM_STRING;
// Make model current obj
status = ProMdlToModelitem (solid, &modelitem);
status = ProParameterInit(&modelitem, name, ¶m);
// If the parameter doesn't exist in the model, create it in the model
// with empty string. Otherwise get its current value.
if (status == PRO_TK_E_NOT_FOUND)
{
ProStringToWstring(value.value.s_val, ");
status = ProParameterCreate (&modelitem, name, &value, ¶m);
}
else
{
status = ProParameterValueGet(¶m, &value);
}
ProWstringToString(astr, value.value.s_val);
// Make drawing current obj
status = ProMdlToModelitem ((ProMdl)drawing, &modelitem);
status = ProParameterInit(&modelitem, name, ¶m);
// If the parameter doesn't exist in drw, create it with empty string.
// Otherwise set it's value to the same as from the model.
ProStringToWstring(value.value.s_val, astr);
if (status == PRO_TK_E_NOT_FOUND)
{
status = ProParameterCreate (&modelitem, name, &value, ¶m);
}
else
{
status = ProParameterValueSet(¶m, &value);
}
}
Tommy