About the SUFaceGetFrontMaterial function return

when I call this function, it return 9 . I know it is enum by finding file ,but this return is not in the function’s file, I don’t know what it means. Thank you.

See the documentation …

There are several possible error codes returned. There error enumeration is …

… and the member at index 9 is SU_ERROR_NO_DATA, which means (as told in the enum’s docpage):

“The requested operation has no data to return to the user. This usually occurs when a request is made for data that is only available conditionally.”

Assuming that the face is a valid object, and the material reference was properly created and ready to receive a material from the function call, I would surmise that it means that the face has no material property assigned to it’s front.


@thomthom, the OP is mentioning that the function’s doc does not list this return value and what it means in the context of calling this function.

I think you are right in a way , because when I use the “pepperoni.skp” and the SUFaceGetFrontMaterial function , it is successful and I get the color from material , but when I use the “pepperoni.skp” and the SUFaceGetBackMaterial function , it fails.
But when I use the "Alias+860_Eleven.skp " , no matter what I use the SUFaceGetFrontMaterial function or SUFaceGetBackMaterial , it fails , even I think it have color.
Thank you.

You also need to check if an instance or group has a material assigned, which is displayed onto faces that have nil assigned. (Ie it means their material is “defaulting” to their parent’s material.

Thank you , I will try.

Thank you , but when I watching the file of group and component_instance I find they can’t get material.

You have to cast them to a SUDrawingElementRef …

Thank you , I will try it.

Thank you, I get the material from the drawingelememt .

1 Like

The only reason SUFaceRef have material getters and setters are because faces have front and back materials. For all other entities you need to cast to SUDrawingElementRef.

1 Like

… but wouldn’t ya’ say that because of the frequency of material checks on group and instance objects, that fast wrapper functions would be welcome ?

Given the amount of other issues where the API is lacking parity, such convenient access wrappers would end up very low on the priority list. Remember, everything needs peer review and QA testing and has its cost.
This is one of these cases where an API user quickly writes a utility function and reuses that.

Thank you.

Thanks for your help.
I have a question, I want to know whether the faces in the child entities of group or instance will use the material of themselves.
If it is , what time should I use them?
When I was testing , a model named 005.skp didn’t had a right result , some place that should have texture was filled by color.
I haven’t found this condition from other model that I use to test up to now.
And what’s more , I find a model named assembl13b.skp has no material but it has color when I use sketch up to open it.
You think where should I get the color ?
Thank you.

It is actually the definition (of the group or instances) that has child entities. If these entities have materials directly assigned, then the SketchUp rendering engine will use their direct assigned materials.

Did you have Shaded with Textures as the rendering mode ?

Without seeing the model(s) … I’d just be guessing.

Thanks for your help.
I find I did’t deal the faces’ material of child entities that are directly assigned, I will try it , thank you.
You can get the model from the address :https://3dwarehouse.sketchup.com/model/5a8dfe06-0d11-4095-9bd7-292356ca71db/Underwood-project-phase-2b
Thank you.

The attached model uses ‘Color by Layer’ style option.
If this option is enabled, materials are taken from layers not from faces.

SUModelGetRenderingOptions(modelRef, &renderingOptions);
SUTypedValueCreate(&typedValue);
SURenderingOptionsGetValue(renderingOptions, "DisplayColorByLayer", &typedValue);
SUTypedValueGetBool(typedValue, &isColorByLayer);
SUTypedValueRelease(&typedValue);
1 Like

Thank you.
Thanks for your help.