Count sub-components with the definition "TOTO"

It is better than is was, but still not totally correct … ie …

  sel.grep(Sketchup::ComponentInstance).each {|s|
    s.definition.entities.grep(Sketchup::ComponentInstance).each {|e|
      array << e if e.definition.name=~match
    }
  }

… and for the THIRD time …

READ THIS! :arrow_right: [How to] Colourize code on the forum? (pinned topic)

Settings (menu) > Preferences… (dialog) > Language (panel)

Tab Settings (group) > ruby (choice)

  1. uncheck “Use default value”
  2. set “Tab size” to 2
  3. check “Replace by space”

You can also switch on “Auto-Completion” but you may need to get an autocomplete xml file for Notepad++. @tt_su made one at one time. You may be able to use the stubs at the SketchUp GitHub repo: > GitHub - SketchUp/ruby-api-stubs: Auto-generated stubs for the SketchUp Ruby API. Useful for IDE intellisense and auto-complete.
(This is a complex issue and there are other threads on this. We are going too far off-topic as it is.)

Notepad++ has it’s own forums where you should ask questions:
Home | Notepad++ Community

Settings (menu) > Style Configurator… (dialog) > Language (picklist)

  1. choose “Ruby”
  2. choose a style from the “Select theme:” drop down control
    (You can further modify the chosen style afterward.
    My style is based on “Deep Black” with certain feature color changes, such as I changed “INSTRUCTION”, which are keywords to a bright orange.)
  3. You must also make some global changes to the “Global Styles” (at top of “Language” picklist,) and it will apply to all coding languages. (I myself set “Consolas” as the global font for all coding.) Many of the global style features cannot be set per language.
  4. press “Save & Close” button when done.