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!)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement