Components to Groups

Hello! Hope you guys can help!

I’ve been trying to write a ruby script that iterates through all the components in the active skp model and removes their component definition turning them into simple groups of geometry. Similar to the process of exploding a component and grouping it.

The reason I want to do this because I’m importing .fbx content from Revit using the fluid importer plugin which imports a component definition for each piece of geometry ballooning the file size! and now I have almost 10000 unique component definitions! and my .skp model is almost 400MB!

Any advice would be greatly appreciated! Thanks!

A Group and a ComponentInstance both use a ComponentDefinition to hold their geometry. Converting from Components to Groups will save only a minimal amount of memory (Components have a few attributes that Groups do not). Likewise, converting from Components to loose geometry (exploding) won’t save all that much memory and will risk having them all interact with each other. What you really need to avoid ballooning is some way of identifying any instances that contain the same primitive geometry, just moved, rotated, or scaled, so that they can share the same ComponentDefinition. That is a much harder problem!

Hey thanks for your reply!

I didn’t realize that both components and groups both have component definitions and yes cross checking across 10K components for geometrical similarities would take a lifetime!

However on a more mundane note, every time I open the component browser the computer freezes for 15 mins loading thousands of components so it would still be really handy script to have!

I’m used to writing in Java and JS so I’m still trying to learn ruby and the SKP API… so yeah any pointers that can get me started would be really appreciated. Will keep trying and post if I can get something working! Thanks again!

-K

Sorry I forgot to mention that once the components have been converted into groups, I can just “purge un-used components”… well that’s the idea anyway. :smile:

Purging unused components will rid your file of the duplicate component definitions (one for the original component and one for the replacement group). But until the unused definitions are purged, the size of your file will temporarily double! You need to delete each old component definition as soon as you create the equivalent group. So far as I know, there is no way to simply “relabel” a component as a group.

But, as I said earlier, merely converting from components to groups won’t actually shrink your file by much.

Also, the outliner is notorious for bogging down when you have too many components OR groups. Converting to groups won’t help with that.

Returning to basics, why are there so many components in your imported model? Maybe you could structure things better before the export/import so that a) larger amounts of geometry are gathered into each component or b) identical objects are recognized as such in Revit before export? I’m not a Revit or fluid importer user, so I can’t help you with those steps - just ideas to consider.