Explode and regroup script?
-
The problem is some groups being dropped on "top" of others already moved to the surface.
So to avoid that conflict, I have modified the previous code I posted.
mod = Sketchup.active_model sel = mod.selection gat = [] sel.grep(Sketchup;;Group){|g| o = [g.bounds.center.x,g.bounds.center.y,g.bounds.min.z] p = mod.raytest([o,[0,0,-1]])[0]; gat<<[g,Geom;;Transformation.new(p-g.bounds.min)] if p } gat.each{|g| g[0].transform!(g[1])}
-
@sdmitch said:
The problem is some groups being dropped on "top" of others already moved to the surface.
So to avoid that conflict, I have modified the previous code I posted.
mod = Sketchup.active_model > sel = mod.selection > gat = [] > sel.grep(Sketchup;;Group){|g| > o = [g.bounds.center.x,g.bounds.center.y,g.bounds.min.z] > p = mod.raytest([o,[0,0,-1]])[0]; > gat<<[g,Geom;;Transformation.new(p-g.bounds.min)] if p > } > gat.each{|g| g[0].transform!(g[1])} >Oh my God, thank you so much, sdmitch!!
It is working perfectly!!

-
Always amazazed that few line can make! Bravo!

-
@sdmitch said:
The problem is some groups being dropped on "top" of others already moved to the surface.
So to avoid that conflict, I have modified the previous code I posted.
mod = Sketchup.active_model > sel = mod.selection > gat = [] > sel.grep(Sketchup;;Group){|g| > o = [g.bounds.center.x,g.bounds.center.y,g.bounds.min.z] > p = mod.raytest([o,[0,0,-1]])[0]; > gat<<[g,Geom;;Transformation.new(p-g.bounds.min)] if p > } > gat.each{|g| g[0].transform!(g[1])} >I'm sorry, Sdmitch... There is still one problem..

The groups are moving by Z axis perfectly, but when it goes down to terrain, they are changing their X and Y positions. They are messing with each other..
Why is it happening? -
@gregswk said:
@sdmitch said:
The problem is some groups being dropped on "top" of others already moved to the surface.
So to avoid that conflict, I have modified the previous code I posted.
mod = Sketchup.active_model > > sel = mod.selection > > gat = [] > > sel.grep(Sketchup;;Group){|g| > > o = [g.bounds.center.x,g.bounds.center.y,g.bounds.min.z] > > p = mod.raytest([o,[0,0,-1]])[0]; > > gat<<[g,Geom;;Transformation.new(p-o)] if p > > } > > gat.each{|g| g[0].transform!(g[1])} > >I'm sorry, Sdmitch... There is still one problem..

[attachment=2:kcc5danh]<!-- ia2 -->Capture2.JPG<!-- ia2 -->[/attachment:kcc5danh]
[attachment=1:kcc5danh]<!-- ia1 -->Capture3.JPG<!-- ia1 -->[/attachment:kcc5danh]
The groups are moving by Z axis perfectly, but when it goes down to terrain, they are changing their X and Y positions. They are messing with each other..
Why is it happening?Oops. My bad. I forgot to change the "origin" in the transformation. Code has been fixed.
-
@sdmitch said:
Oops. My bad. I forgot to change the "origin" in the transformation. Code has been fixed.
Wonderful, Sdmitch!
Now it is perfect!!!

Thank you so much!!!
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