Move groups with different measures?
-
Before testing your new randomizer plug

I have a little problem

I have used "Grow" by Tig for make the "volume" on the left (50 groups), then my "Plug" Thomthomised
with a normal interval of course!
Seems there is something wrong somewhere
Groups are not recorded following the "grow" generation?

-
So i must use the Tig Advertissement more soon than I have expected

-
This group.bounds.min.z. can be found somewhere or the sorting of Groups must be forged again?
(nothing about sort, sorting in the API helping)
-
Build a hash with the entities as the key and their Z posiiton as value and then sort the hash by the values.
-
Each groups has not a "time creation" trace board? So no need to remake a sorting ?
Seems I have re-open a new nightmare door
-
Awesome Pilou! Keep it up, its looking great. You've got lots of good help around here.
Chris
-
Try something like...
zeds=[] index=0 groups.each{|group| zeds.push(group.bounds.min.z, index) index+=1 } zeds.sort! sorted_groups=[] zeds.each{|z|sorted_groups.push(groups[z[1]]) } ### sorted_groups is now groups sorted by Z -
Does the group.bounds.min.z only valuable in SU 7?
Edit seems not
little try but seems I miss something
(any doubt selection but the sorted_groups gives nothing on the screen)model = Sketchup.active_model entities = model.entities selection = model.selection groups = [] z=0 zeds=[] index=0 groups.each{|group| zeds.push(group.bounds.min.z, index) index+=1 } zeds.sort! sorted_groups=[] zeds.each{|z|sorted_groups.push(groups[z[1]]) } ### sorted_groups is now groups sorted by Z sorted_groups.each do |e| point = Geom;;Point3d.new 0,0,z t = Geom;;Transformation.new point e.transform!(t) z = z + 1000.mm end -
it's like a snowball on the top of the mountain


-
groups = [] then nothing set !!!
You emptied the groups array...
You need to fill it from the selection...
groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup;;Group)} -
another try found: undefined method โ[]โ

model = Sketchup.active_model entities = model.entities selection = model.selection z=0 zeds=[] index=0 sorted_groups=[] groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup;;Group)} groups.each{|group|zeds.push(group.bounds.min.z, index) index+=1 } zeds.sort! zeds.each{|z|sorted_groups.push(groups[z[1]]) } ### sorted_groups is now groups sorted by sorted_groups.each do |e| # update! # Now we process the groups point = Geom;;Point3d.new 0,0,z t = Geom;;Transformation.new point # Apply the transformation e.transform!(t) z = z + 100.cm end -
Is that the only error message you get?
@unknownuser said:
it's like a snowball on the top of the mountain

You're hooked now! No way back!

-
Here's some tweaked code
def test() model = Sketchup.active_model model.start_operation("Move in Z") entities = model.entities selection = model.selection zeds=[] index=0 sorted_groups=[] groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup;;Group)} groups.each{|group|zeds.push([group.bounds.min.z, index]) index+=1 } zeds.sort! zeds.each{|z|sorted_groups.push(groups[z[1]]) } ### sorted_groups is now groups sorted by z = 0.0 sorted_groups.each do |e| # update! # Now we process the groups t = Geom;;Transformation.new(Geom;;Point3d.new(0,0,z)) # Apply the transformation e.transform!(t) z = z + 100.cm end model.commit_operation return nil end#defRuns as '
test'.
I made a typo - it needed an array[]of two items adding tozeds: zeds.push([group.bounds.min.z, index])not two 'loose' items as inzeds.push(group.bounds.min.z, index).
I made yourz = 0intoz = 0.0as it needs the number as a float, not an integer...
Removed 'point' variable and set the point definition directly inside the transformation - not necessary but fewer variables...
I added amodel.start_operation("")...model.commit_operationso it becomes a one step undo.
I addedreturn nilat end so the Ruby-Console doesn't get clogged with info...Tested it - it works...
-
Seems indeed that some corrections were necessary

This time works like a charm! Excellent! TIG + Thomthom! Bravo!
I will see all that more in detail for learn this little cryptic language !
Very funny plug!
For the next Pilou's foolish...
...I need to know the "centroรฏd" (xyz) of a "bounding box's group"
Here of course without different measure, just for little test!
(click image)

-
@unknownuser said:
...I need to know the "centroรฏd" (xyz) of a "bounding box's group"
centre_point=group.bounds.centerSee http://code.google.com/apis/sketchup/docs/ for all these details

-
Thx I had missed this one

-
It'd help if you posted the error messages.
However, I can still see the problem here.
Sketchup::Componentisn't an SU object. Check the manual, you haveSketchup::ComponentDefinitionandSketchup::ComponentInstance. In your case you're looking for aSketchup::ComponentInstance. -
I have replaced "Group" by "Component" but seems that is not so simple

groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup;;Component)} groups.each{|component|zeds.push([component.bounds.min.z, index])Else I can yet nest a component inside a group color transparent

That works fine (just disable Edges visible) but I suppose there is another thing

-
@ Tig Some cryptic but I will see that

Joint an image for no ambiguities
So here the increment is 300 cm
Edit sorry I have not seen all these speedy results!
@Thomthom! Yes that is that ! e.transform!(t)


-
Come back in these very dangerous territories

As I understand that retrieve the center XYZ of the bounding box group by
center = boundbox.centerbut how give these 3 values(?) to these 3 variables ?

xc= ?
yc= ?
zc= ?
must be trivial but yet some foggy for me
PS I read the API from the end to the start, and inverse but this stay mysterious found anything except that
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