Can't get material

I use these two function that are SUFaceGetFrontMaterial and SUFaceGetBackMaterial to get material from face.
I find sometimes it will return 9.
Maybe it is because the face has no material in front or back.
I think I can’t get the material sometimes even I think it should has material.
Thank you.

@thomthom, the docs say these functions return SU_ERROR_NULL_POINTER_OUTPUT (3) if the material is NULL. Do the functions actually return SU_ERROR_NO_DATA (9) in these cases ?

If the face itself does not have a material directly assigned, then the display engine will display the parent group’s or instance’s material upon the face (if the parent has a material assigned.)

Thank you.
In fact, I think I have try to deal the father material.
For each face, I will try to get the material that directly assigned.
If it has no material directly assigned , I will detect the father material .
If it has no father material, I will deal it as no material.
I find some result is not right in my code, I think maybe the reason is these place that should have materials have no material.
The reason that I think maybe some places has material is that the result is right when I open this model by simlab ,and the simlab show the component has material.
When I use myself plugin , I find these places are filled by defaulty color.
I think some of the components that use the material are normal and other are unnormal in my code.
Maybe I’m not right, I’m sorry.
Thanks for you help.

Correct, when there is no material it returns SU_ERROR_NO_DATA. The docs are incorrect.
SU_ERROR_NULL_POINTER_OUTPUT is returned if the SUMaterialRef * material is NULL.

The docs for SUDrawingElementGetMaterial is correctly describing what SUFaceGetFrontMaterial and SUFaceGetBackMaterial should describe.

1 Like

If that’s the case, then please post back with an example model an minimal code example to reproduce.

Thank you.