Skip to main content
1-Visitor
April 7, 2014
Question

Assigning Material to Model

  • April 7, 2014
  • 1 reply
  • 888 views

Hello,


I am trying to attch a material to a Creo part usingProMaterialfileRead() ,ProMaterialCurrentSet(), ProMaterialCurrentSet().


Altough the material gets added to part's database its not getting assigned to the part.


Does anyone know any API/function which can do the same ??


Regards,


Shreeshail




This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

1 reply

15-Moonstone
April 7, 2014

Hi,


I use the same function to do what you want to do.


ProMaterial p_material, o_material;
ProError ret = PRO_TK_NO_ERROR;
// LOAD YOUR MATERIAL SOMEWHERE HERE : )
p_material.part = (ProSolid)mdl;
wcscpy_s(p_material.matl_name, PRO_NAME_SIZE, materialname);
ProMaterialCurrentGet((ProSolid)mdl, &o_material);
if (_wcsicmp(o_material.matl_name, p_material.matl_name) != 0) {
//change material because it's a new one
ret = ProMaterialCurrentSet(&p_material);
if (ret != PRO_TK_NO_ERROR) {
writeRunnerLogLangDep(MAT_AM_CANT_SET_MATERIAL_AS_CURRENT, 2);
} else {
writeRunnerLogLangDep_d(MAT_AM_MATERIAL_IS_SET_AS_CURRENT, 0, 1);
setCost(1);
}
}


At my side this works since WF 4.0 till Creo 2.0


Best regards,
Eike