Tela que liste componentes salvos como miniatura identica as opções do componente

Preciso criar uma janela que liste todos meus componente que estão na pasta selecionada e que me permita adicionalos ao meu modelo.

Consegui chegar até aqui, mais não me mostra so mesmo jeito que está nas opções do componente.

Alguem pode me ajudar ??

I’ve had trouble with this as well. It seems I had the most trouble in SU 22. You can try cutting and pasting from older saved versions of components into empty newer versions. When you do, make sure “Redefine thumbnail on save” is selected in Model Info → File.

Also, if you have Trays open, those seem to offset the image. For example, I have two Trays on the right so I move further to the left than ‘normal’ to get a better thumbnail.

Here is an example showing the same component, just re-saved from SU 22 to SU 24 open in my folder browser extension.

Screenshot 2024-07-22 205533

Here I resaved a few times just to show the result.

Screenshot 2024-07-22 210002

If you are creating a thumbnails folder with your extension, recreate them after re-saving.

Eu verifiquei e está correto.

Me explique melhor essa abordagem por favor!

I create the directory if it does not exist. So, if I want to update them I delete the folder that contains the thumbnails. Then it is recreated when I open the extension again. But you could modify the code.

img_dir = File.join(selected_folder, 'comp_thumbnails')
Dir.mkdir(img_dir) unless Dir.exist?(img_dir)

Maybe add a way to delete thumbnails and then call create_thumbnail to update them?

skps.each do |skp_name|
  basename = skp_name.sub('.skp', '')
  img_name = "#{basename}.png"
  skp = File.join(selected_folder, skp_name)
  img = File.join(img_dir, img_name)

  # Generate thumbnail
  create_thumbnail(skp, img)
end

I probably wouldn’t want to create thumbnails every time…

def create_thumbnail(skp, img)
  Sketchup.save_thumbnail(skp, img) unless File.exist?(img)
end

But -without testing- I think this would do that:

def create_thumbnail(skp, img)
  Sketchup.save_thumbnail(skp, img)
end

Again, you may want to find a way to delete/replace the thumbnails first to avoid problems.