Christina and Chris D, and others no doubt, have made code for taking care of text that has gone to an infinite distance away. It works by looking for NaN values in the point of the text object.
I have a customer’s model where five text objects, some dimensions, and even a construction point, are all in illegal territory. The point check that works for text doesn’t work for dimensions or construction points, so I looked at the bounding box for a while. Unfortunately, the center of a completely illegal bounding box is a legal value, (0,0,0) usually. So I started looking at the corners, and then at the max and min values.
There are some problem cases where the object is a long distance away and cause problems, but not far enough away to be NaN. So, I check for anything that is an unreasonable distance away in any direction. These are my lines of Ruby now (the first line is Christina’s one for just taking care of the text):
Sketchup.active_model.active_entities.grep(Sketchup::Text).each { |t| t.erase! if t.point.to_a.any?(&:nan?) }
Sketchup.active_model.active_entities.grep(Sketchup::Drawingelement).to_a.each { |t| t.erase! if t.bounds.max.x>100000 }; nil
Sketchup.active_model.active_entities.grep(Sketchup::Drawingelement).to_a.each { |t| t.erase! if t.bounds.max.y>100000 }; nil
Sketchup.active_model.active_entities.grep(Sketchup::Drawingelement).to_a.each { |t| t.erase! if t.bounds.max.z>100000 }; nil
Sketchup.active_model.active_entities.grep(Sketchup::Drawingelement).to_a.each { |t| t.erase! if t.bounds.min.x<-100000 }; nil
Sketchup.active_model.active_entities.grep(Sketchup::Drawingelement).to_a.each { |t| t.erase! if t.bounds.min.y<-100000 }; nil
Sketchup.active_model.active_entities.grep(Sketchup::Drawingelement).to_a.each { |t| t.erase! if t.bounds.min.z<-100000 }; nil
The lines fix the model, but not without doing 10x zoom extents. Here is a video of how the model changes after the repairs are done, and up to 10 zoom extents later. Note how it also has the problem where the blue axis is solid downwards, no dotted blue up axis line, at least until around the 4th zoom extents.