0

How to change material property of an imported model3D ?

lioneloddo 5 years ago in Question updated 5 years ago 1
Hi,
I'm trying to change the color of a model3D that has been previously imported from an STL file like this:
CurrentModel = HelixToolkit.Wpf.ModelImporter.Load(Path);
where CurrentModel is a model3D. The default color for stl file is blue.

If I want to change its material properties, it's nesserary to use a GeometryModel3D...
var GeoModel = CurrentModel as GeometryModel3D

Then material properties are enabled ...
GeoModel.Material = Materials.Gray;

To add this model to my view, I create a ModelUIElement3D...
ModelUIElement3D ModelUI = new ModelUIElement3D(); and add it ...
ModelUI.Model = geoModel;

Next step should be to add the ModelUIElement3D to the view...
view.Children.Add(ModelUI);

But that doesn't work...
Any ideas ?
Thanks
Lionel
As usual when programming, things don't work due to stupid errors...

Here, defining CurrentModel as a Model3DGroup instead of a Model3D allows to solve the problem.