@colin, I’m glad that this helped.
AnsenSeale, the code I posted above had some nasty side effects that would appear in a more complicated scenario. Here’s a better solution (I hope).
module SW
module M15fix
def self.rescale(obj)
m = obj.transformation.to_a
if m[15] != 1.0
p obj
[ 0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13,14].each { | i | m[i] = m[i] / m[15] }
m[15] = 1.0
tr = Geom::Transformation.new(m)
obj.transformation = tr
end
end
# Search through the entites and rescale any group or component were the matrix element 15 is not 1.0
#
def self.recurse(ents)
ents.each { | obj |
if [Sketchup::Group, Sketchup::ComponentInstance].include? obj.class
rescale(obj)
recurse(obj.is_a?( Sketchup::Group ) ? obj.entities : obj.definition.entities)
end
}
end
model = Sketchup.active_model
ents = model.active_entities
model.start_operation('m15 Repair')
recurse(ents)
model.commit_operation
puts 'm15 repair completed'
end # M15fix
end # SW
nil
Edited: removed an undocumented method call ( obj.transformation = Array )