@artmusicstudio said:
now, i think of finding a way to iterate depending of the Z height.
is there a way to say directly in the iteration routine, start with lowest elements and go up to the highest?
You make an array COPY of the collection, and the sort the array using the sort() method that is mixed in from the Enumerable module.
Use the entity bounds() method to get a Geom::BoundingBox, and it's min() method to get a Geom::Point3d, and use it's z() method to get Length objects for the compare expression.
def z_sort(coll)
coll.to_a.sort {|a,b|
a.bounds.min.z <=> b.bounds.min.z
}
end
The trick is that the Comparable module must be mixed into the final object's class, on both sides of the compare <=> operator. This will always be true for Numeric and String subclasses. At the console:
Length.ancestors %(darkgreen)[>> [Length, Float, JSON::Ext::Generator::GeneratorMethods::Float, Numeric, Comparable, Object, JSON::Ext::Generator::GeneratorMethods::Object, Kernel, BasicObject]]
Notice that Comparable is already mixed in ?