Use Sketchup sdk to read skp texture related issues



Now I want to read the skp file and display it in my view. I have obtained the information of the triangulation. Now I need material information and texture information. Therefore, I found the sdk, “SU_EXPORT SUTextureRef SUTextureFromEntity(SUEntityRef entity);” to get the texture through the entity. However, there is always no texture. I will give the code below, I hope that God will explain it to me. Grateful

 aTru = SUEntityListIteratorNext(iterator);
 			 SUEntityRef pEnt = SU_INVALID;
 			 aTru = SUEntityListIteratorGetEntity(iterator, &pEnt);
 			 SUTextureRef atexture = SU_INVALID;
 			 atexture = SUTextureFromEntity(pEnt);
 			 if (SUIsValid(atexture))
 				 atexture = SUTextureFromEntity(pEnt);

why atexture is empty?Is my way wrong?
I used the following method to convert SUEntitiesRef to SUEntityRef and then read the texture.

SU_RESULT SUEntitiesEntityListFill(SUEntitiesRef entities,enum SURefType type, SUEntityListRef list);
SU_RESULT SUEntityListBegin(SUEntityListRef list,SUEntityListIteratorRef* iterator);
SU_RESULT SUEntityListIteratorGetEntity(SUEntityListIteratorRef iterator,SUEntityRef* entity);
SU_EXPORT SUTextureRef SUTextureFromEntity(SUEntityRef entity);

I hope to help me answer!please!!!thanks!!!


I have changed the category, for the lesser ones amongst us can explain it, too…


I’m sorry, I do not understand what you mean


He meant it belongs into the “SketchUp SDK” category of the forum and he moved it there.

If you format your code as code (edit it, select it, click the </> button), it becomes also more readable. Thanks!


oh i know! thanks!!!


Are you looking to obtain the texture files? Or the UV data for each face?


yes!Like this, I have a file xxx.skp . This is a textured file, now I want to parse this file via sketchup sdk. Now I want to get the texture of the file and the uv coordinates of each face.I don’t know how to get it.


In short, try to examine: CApiSDK/Samples/ skp_to_xml/common this is the best place for you to start + it covers a lot of specific cases (components, groups, etc).