The SUStylesMoveStyle function cannot delete a specified style, and the image obtained by the SUStyledThumbnail function is only 1kb

char* c_file_path = RSTRING_PTR(file_path);
char* c_thumbnail_dir = RSTRING_PTR(thumbnail_path); 

SUModelRef model = SU_INVALID;
SUResult res = SUModelCreateFromFile(&model, c_file_path);
if (res != SU_ERROR_NONE) {
	rb_raise(rb_eRuntimeError, "Failed to create a new model");
}

SUStylesRef styles;
SUModelGetStyles(model, &styles);

size_t style_count = 0;
SUStylesGetNumStyles(styles, &style_count);
SUStyleRef* style_array = (SUStyleRef*)malloc(sizeof(SUStyleRef) * style_count);

if (style_array == NULL) {
	return EXIT_FAILURE;
}
size_t count = 0;
SUStylesGetStyles(styles, style_count+1, style_array, &count);
for (size_t i = 0; i < count; ++i) {
	SUImageRepRef thumbnail = SU_INVALID;
	SUImageRepCreate(&thumbnail); 
	SUResult thumbnail_result = SUStyleGetThumbnail(style_array[i], &thumbnail);
	if (thumbnail_result == SU_ERROR_NONE) {
		SUImageRepConvertTo32BitsPerPixel(thumbnail);
		char filename[256];
		snprintf(filename, sizeof(filename), "thumbnail_%04zu.jpg", i); 
		
		char full_path[512];
		snprintf(full_path, sizeof(full_path), "%s\\%s", c_thumbnail_dir, filename);
		thumbnail_result = SUImageRepSaveToFile(thumbnail, full_path); 
		if (thumbnail_result != SU_ERROR_NONE) {
			rb_raise(rb_eRuntimeError, "Failed to save thumbnail to file: %s", full_path);
		}
		if (i >1)
			SUStylesRemoveStyle(styles, &style_array[i]);
		printf("Style %zu has a valid thumbnail.\n", i);
	}
	else {
		printf("Style %zu does not have a valid thumbnail.\n", i);
	}
	SUImageRepRelease(&thumbnail); 
}

for (size_t i = 0; i < count; ++i) {
	if (i > 1)
		SUStylesRemoveStyle(styles, &style_array[i]);
	printf("Style %zu has a valid thumbnail.\n", i);
}

memset(style_array, 0, sizeof(SUStyleRef) * style_count);
free(style_array); 
SUModelRelease(&model);
SUTerminate();
return Qtrue;

Please post code correctly in the forum:

It is also best if the description of the problem in in the post, not in the topic title. (For quoting purposes, etc.)


What version of the SDK are you testing on?

I see there are Ruby C API calls in your code. This would indicate that this is a Ruby C extension running inside SketchUp’s process. If so, then this:

SUTerminate();

… should not be called.

using SDK_WIN_x64_2025-0-634

Yes, deleting it did not change the result

I did not think it would.

I also did not see any report similar in the official API Issue tracker:

Would we expect the size to be around 4K ?


This is the result we have obtained so far

I hope to get a thumbnail like Sketchup