Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
π« Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
Quickly finding groups/comps in an Entity Collection?
-
this thread reminds me of this:
http://refactormycode.com/codes/2-ruby-simple-loop
with each consecutive code sample improving on the last
although the only improvement I could possibly add might be:
def miner(ents) for e in ents if e.class==Sketchup;;Group or e.class==Sketchup;;ComponentInstance miner(e.explode) end end end -
Or to compact it as much as I can see, into a one-liner
def xis(a);a.each{|e|xis(e.explode)if e.class==(Sketchup;;Group||Sketchup;;ComponentInstance)};end"xis" == e
XplodeInstanceS
Usage:xis(entities)

PS: a shorter way to do their puts 1 to 10 is this
n=0;p n+=1while n<10

-
I take a few extra lines for readability any day.
-
@thomthom said:
I take a few extra lines for readability any day.
True, but "squish-the-code" is a fun exercise and I often learn something new.
def xis(a);a.map{|e|xis(e.explode)if e.respond_to?('move!')};end(assuming no one has added move! to any of the built-in classes!)
Advertisement