Opening "Components" tray suddenly increases file size dramatically

I just ran into an interesting thing that I can’t explain. I have a model that I have cleaned up carefully, purged, reduced texture sizes, etc. to get the file size down to about 5 MB. It works fine like that, and I’m happy with it. But if I simply open the “Components” tray, without doing anything else (ONLY opening the window; not doing anything in there, not even selecting a component), then I save the file, the size has now suddenly jumped by nearly 70%, to 8.4 MB. Very strange, very explainable. Why would opening that specific window cause it to somehow generate a whole bunch of new stuff inside the model? If I then close the Components tray window again (still without having done anything), and purge it, the file size does not change: it stays at the new 8.4 MB size.

Has anyone seen this before? Why does that happen? Is there anything I can do to get the file size back down to where it was, AFTER I open the components tray?

It seems likely that SketchUp added thumbnail images of every component for use in the Components window. If you have used a lot of components, the memory for these images can be considerable. Purging will not get rid of them unless they are for components you haven’t used in the model.

1 Like

Does this also happen if you have the Components panel set to List mode ?

does the the actual file size increase after saving or is it just the in-memory file size shown in preferences?

john

That makes sense. I guess that dould be it, even though I have thumbnails turned off in the “Scenes” menu, I imagine that doesn’t apply to components. Is there any way of deleting those thumbnails? Maybe a plug-in? There’s hudreds of components in the model, so that would expñain the increased file size.

Yes. It is set to list mode.

Its the actual file size on disk that changes.

That’s interesting. Probably SketchUp is generating all images when the panel opens, even though they aren’t needed. Sounds like there is some room for optimization here!

3 Likes

I was able to track this down several years ago. I brought it up to Trimble but to no avail.

I wrote a script that created 100 unique components. Each one a simple rectangle. Each positioned slightly different.

The script executes very quickly. Then create a rectangle and turn it into a component. Sketchup freezes for quite a while as Sketchup is creating the thumbnails for all 100 components. This happened with or without the component window opened.

Not long afterwards I switched from components to groups in my cabmaker plugin.

4 Likes

“Sounds like there is some room for optimization here!” Perhaps a simple plugin that could go through the model and remove all unwanted thumbnails? That would be very cool! If there were only some great plug-in author around, who could develop such a thing… :slight_smile:

For a long time I’ve suspected that there must be a lot of garbage like this in SketchUp files, since they get so big, so fast, from doing very little.

The model in question, for example, is not complicated, in terms of geometry. There’s about 400 individual components (750 instances), but they are pretty much all simple rectangles, and the textures are just simple wood textures, from SketchUp’s own materials library: nothing complex, no big images. I can’t see how such a file could weight 5 MB in the first place. That implies that each component definition is using up about 15 kb… doesn’t seem reasonable, if there’s only info abut geometry in there, but makes more sense if each has its own hidden thumbnail. (There’s also some Dynamic Component stuff going on, that manipulates those components, but that doesn’t take up much space.) From another point of view, there’s about 6,000 faces in the model, so each face must be taking up nearly 1 kb. So it seems that there must be something else stored in the file that isn’t useful to the model.

It would be great if there were some tool that could strip out the garbage, to make the file lean and clean… and faster too, I suspect!

Unfortunately, the “live” Ruby API only exposes methods to refresh and save (to disk) a component definition’s thumbnail. There is no boolean toggle (yet) to suppress the creation of thumbnail images, nor any remove_thumbnail method.

It’s even worse for the C API when working directly with SKP files. I can find absolutely no functions that get, set, save, delete or otherwise manipulate the component definition thumbnail images.

An external utility would need to know what the exact binary format was for where in the SKP file these thumbnail images were kept, to be able to delete them. This is difficult as the SKP file format changes almost with every yearly major release.

2 Likes

Thanks for the info, Dan. That’s a pity, since the file can get rather bloated unnecessarily if there’s a lot of components in it.

I just realized that Dynamic Components seems to be doing the same thing: for each “component options” window, there’s a thumbnail at the top left that shows how the component looked at some point in the process of generating the model (but not necessarily the way it looks right now). Those, too, must be taking up space, and must require some processing time to generate. I can’t see any way of turning those off either. I don’t need them, they take up space, the use CPU time, and I’d really like to disable them so they never get generated… but it doesn’t seem to be possible either.

Sigh!

Dynamic Components are just components with a special attribute dictionary used by the DC extension’s code. So yes, they’ll do the “same thing”.

I noticed the same issue with components with my plugins and that is why I generally use groups rather than components throughout the Medeek suite of plugins.

Most recently I have switched the slab rebar to groups in the foundation extension:

Version 1.5.3 - 12.12.2019

Updated Slab and SOG reinforcement, replacing components with groups to increase performance.

Garry Kernan was the first to make me aware of this issue and then after my own testing and experience it became obvious that SketchUp was doing something under the hood with components which was slowing and bloating the files.

It actually slows performance or just the saving and opening functions?

If the reason for stripping down the file is to email or upload the file so someone else can view it, I suppose someone could make a script that freezes every component by converting to a group, purging the component library and saving the results as a separate file that’s even flagged as read only.

In photography, the work flow goes from original RAW file through processing and then output to jpg files, typically. Those final files aren’t intended to ever be manipulated again.

The SketchUp API still does not have a instance#to_group method.
(We are forced to do “hacky” slow workarounds usually involving exploding.)

2 Likes

I know, I’ve dealt with this more than once.

Got to say I am rather dissapointed that Trimble have not actioned this long ago… might explain why I had an intuitive preference for groups over components… but also why the horrendous autocad files I have to deal with sometimes (500+ layers, hundreds of embedded blocks (converted to components) bloated the SU file even more…

Trimble… these are bread and butter productivity issues for us that should be addressed as a priority…

1 Like

I guess they are balancing between two worlds. One being the SketchUp Universe that has been taken over by the other, the Trimble Galaxy. There is hope, though.
And there are actions, but I guess it wll take a while for the ‘Under the hood’ changes to surface in the real world.
The way the importers work by not aknowledging instances of definitions being one.
It would be nice to have an option not to generate thumbnails for a model.
This could be managed in the Model Info->File settings

2 Likes