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
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.
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 .
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
… 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.