Yep!!! THX! Miracle that is working!
Sure I should read the Api document before But I had risked the trick
So my second script was a new speedy success and a big lesson
@unknownuser said:
groups=[];selection.each{|entity|groups.push(entity) if entity.kind_of?(Sketchup::ComponentInstance)}
groups.each{|ComponentInstance|zeds.push([ComponentInstance.bounds.min.z, index])
Copy my code follow in the Web console from Jim Foltz
(if you have components use the file linked )
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
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
Some help for fun variations
[image: http://forums.polyloop.net/picture.php?albumid=23&pictureid=421]
Undrop_component.zip