Displaying only materials and components inside model

Hey everyone,

I’m wondering if it’s possible to display only materials and components inside model via Ruby script
Like clicking on the “House” button in the UI

Thanks a lot :slight_smile:

Cheers

If you mean to simulate the action of a user clicking that button so as to shift the Components window or the Materials window to the “in model” list, the answer is “not via the Ruby API”. In general, the Ruby API does not provide interaction with the standard GUI other than to select a Tool. You may be able to find a platform-specific keyboard simulator that does the trick.

If you mean simply to list them in, say, the Ruby Console or in a WebDialog of your own making, the Components’ ComponentDefinitions are accessible via

Sketchup.active_model.definitions

and the Materials via

Sketchup.active_models.materials

You can follow forward from a ComponentDefinition to its #instances to see where ComponentInstances are placed in the model (or not). So far as I know the only way to find out whether Materials are used or not is to search the model (recursively into nested entities); a Material has no pointer to where it is used.

Hi,

Thanks for your answer.
I meant “to simulate the action of a user clicking that button”.

So I guess it’s not possible straight away…