How to get the material of component?

The SketchUp engine is C++ which is object-oriented. So goes the SketchUp DOM (Document Object Model) and the Ruby API.

Everything saved into DOM is a subclass of Entity. (ie, Layer, ShadowInfo, Material, etc.) The DrawingElement class is a subclass of Entity, and like it’s siblings inherits functions (aka methods,) constants, etc., from it’s superclass(es), all the way back to Object.) Anything that you can see or draw into the model, is an instance of a class, that is a subclass of DrawingElement. (The Face class for example, is a subclass of DrawingElement.)

But the new reading & writing API is C. You don’t clearly see in it, the object-orient inheritance of the SKP document’s DOM. So they mimic it with functions named similarly to how they’d be named in the OO languages. In Ruby you’d have Sketchup::Face.material(), but in C, they concatenate the whole object qualification together in one long name like: SketchUpFaceGetMaterial(). (Just an example, not an exact function name, per se.)

No it’s not. Assign persisting materials to the component instance(s), not their definition.

… and leave all the primitives in the definition’s entities collection with no material assignment, and they’ll render with each instance’s material assignment.

The assignment of a material to a component definition, will only render whilst a new component instance is being placed (ie, when it is attached to the cursor.)

It is sort of a highlighting effect. (“Here I am, insert me someplace good!”)