简体   繁体   English

如何在 Sketchup 中获取组的材质?

[英]how to get the Material of group in sketchup?

I have done iterating through the entities in a group, getting all the faces, and then getting the material of each face.我已经完成了对组中实体的迭代,获取所有面,然后获取每个面的材质。 However, if the material belongs to a group, there is no material on the face.但是,如果材质属于一个组,则面上没有材质。 How do I get the material of the group in this case?这种情况下如何获取群的资料? I use the C API.我使用 C API。

I found the answer, convert the group object into an entity, and then get the texture of the entity through the SUTextureWriterLoadEntity method。我找到了答案,将组对象转换为实体,然后通过SUTextureWriterLoadEntity方法获取实体的纹理。

SUGroupRef _group;
long EntityTextureId = 0;    
SUTextureWriterLoadEntity(m_uvWrite, SUGroupToEntity(_group), &EntityTextureId)

A face can have a front material (and back material) and still be in a group with a group material.一个面可以有一个正面材料(和背面材料),并且仍然与一个组材料在一个组中。 In fact it's very common.事实上,这是很常见的。 In that case, the face material takes precedence over the group material.在这种情况下,表面材料优先于组材料。

SU_RESULT SUFaceGetFrontMaterial(SUFaceRef face, SUMaterialRef* material);
SU_RESULT SUFaceGetBackMaterial(SUFaceRef face, SUMaterialRef* material);

In addition, there is a much more direct way to get the material of a group.此外,还有一种更直接的方式来获取组的材料。

SUDrawingElementRef draw = SUGroupToDrawingElement(group);
SUMaterialRef material = SU_INVALID;
SUDrawingElementGetMaterial(draw, &material);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM