Need Help to fix my SKP file!

Here’s a fuller version of @eneroth3 's code.
It checks for rogue Text in both the model’s entities and all definitions.
It also switches any problem-text’s layer and visibility ‘on’, then moves the Text to the ORIGIN [0,0,0].
It also tries to force the model to zoom-extents after the text is relocated…
Finally it selects the problem-text [in the Model] and allows the user to press Delete to erase it if desired.

model = Sketchup.active_model
model.start_operation("TextCheck", false)
ss = model.selection
txts = []
ctr = 0
puts "\nChecking Text in Model...\n\n"
model.entities.grep(Sketchup::Text).each{|t|
  if t.point.to_a.any?(&:nan?)
    ctr+=1
    puts "#{ctr}: \"#{t.text}\" on Layer \"#{t.layer.name}\" @ #{t.point.to_a} - relocated at [0, 0, 0]"
    t.point=ORIGIN
    t.bounds.clear
    t.layer.visible = true
    t.hidden = false
    txts << t
  end
}
dtxs = []
ctr = 0
puts "\nChecking Text inside Definitions...\n\n"
model.definitions.each{|d|
  d.entities.grep(Sketchup::Text).each{|t|
    if t.point.to_a.any?(&:nan?)
      ctr+=1
      puts "#{ctr}: Defn \"d.name\" : Text = \"#{t.text}\" on Layer \"#{t.layer.name}\" @ #{t.point.to_a} - relocated at [0, 0, 0]"
      t.point=ORIGIN
      t.bounds.clear
      t.layer.visible = true
      t.hidden = false
      dtxs << t
    end
  }
  d.invalidate_bounds
}
view = model.active_view
if txts[0]
  model.bounds.clear
  bb = Geom::BoundingBox.new
  bb.add(ORIGIN)
  model.bounds.add(bb)
  view.refresh
  puts "\nTrying to force Model 'Zoom Extents' - please wait, it might take several seconds..."
  puts "\nThe relocated Model Text will now be Selected - after it completes press Delete if desired..."
  puts "\nAny problem Text relocated inside Definitions must be manually edited..." if dtxs[0]
  ss.clear
  ss.add(txts)
  3.times{
    view.zoom_extents
    view.refresh
  }
  model.commit_operation
  view.refresh
  puts "\nDone."
elsif dtxs[0]
  puts "\nAny problem Text relocated inside Definitions must be manually edited..."
  puts "\nDone."
  view.refresh
  model.commit_operation
else
  puts "\nNo Text problems found..."
  model.abort_operation
end
puts
5 Likes