The onOpenModel callback is being called twice from the same observer.
(For comparison, after I’ve opened two model windows and I switch windows to activate the other model, the onActivateModel callback is only being called once, as expected.)
Steps:
- Open an existing model in a fresh instance of SketchUp.
- Define the observer class in the Ruby console
- Instantiate the observer class and attach the instance
- Open a model via Sketchup.open_file
Is something strange going on here, or am I just missing something glaringly obvious?
Thanks in advance for the help.
Ruby console output:
class TestObserver
def expectsStartupModelNotifications
return false
end
def onOpenModel(model)
puts "opened model #{model.path} from observer #{self.object_id}"
end
def onActivateModel(model)
puts "activated model #{model.path} from observer #{self.object_id}"
end
end
=> :onActivateModel
tt = TestObserver.new
=> #<TestObserver:0x0000000345cb6428>
tt.object_id
=> 980
Sketchup.add_observer tt
=> true
Sketchup.open_file(Sketchup.active_model.path, with_status:true)
opened model /Users/AlexZahn/Downloads/temp/temp.skp from observer 980
opened model /Users/AlexZahn/Downloads/temp/temp.skp from observer 980
=> 0
Sketchup.open_file("/Users/AlexZahn/Downloads/temp/temp copy.skp", with_status:true)
opened model /Users/AlexZahn/Downloads/temp/temp copy.skp from observer 980
opened model /Users/AlexZahn/Downloads/temp/temp copy.skp from observer 980
=> 0
activated model /Users/AlexZahn/Downloads/temp/temp.skp from observer 980