Closed DG1987 closed 5 years ago
I managed to get a working code to modify the material, but I have no idea how to insert this in CreoSon:
// Set Material of part.
ModelType modeltype = model.GetType();
System.out.println("CurrentModel: " + model.GetType());
if (modeltype.equals(ModelType.MDL_PART)) {
System.out.println("Model is part");
fileName = fileName.replace(".mtl","");
File file = new File(fileName);
session.ChangeDirectory(file.getParentFile().getAbsolutePath());
// Retrieve the material item.
Material newmaterial = ((Part) model).RetrieveMaterial(file.getName());
((Part) model).SetCurrentMaterial(newmaterial);
System.out.println("Changed Material of part: " + fileName);
return "true";
}
Thanks for that. I've checked in code changes to add some new functions for handling materials. The new functions will be included in the next release.
file : load_material_file file : set_cur_material file : get_cur_material file : list_materials file : delete_material
Thank a lot, Looking forward for the next release :)
Just Tested the new release functions (dimension set, material set, material load, dimension list). It works! Thanks a lot.
I would propose a new function for Creoson:
file : Set_Material => add a Material for a file, with an option to also activate the material (activating the material is also possible by changing parameter [PTC_MATERIAL_NAME])