# AppObserver onOpenModel callback called twice

**URL:** <https://forums.sketchup.com/t/appobserver-onopenmodel-callback-called-twice/286522>\
**Category:** Ruby API\
**Created:** [August 21, 2024, 5:29pm UTC](https://forums.sketchup.com/t/appobserver-onopenmodel-callback-called-twice/286522 "2024-08-21T17:29:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_lfx](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@alex\_lfx](https://forums.sketchup.com/u/alex_lfx)\
**Post date:** [August 21, 2024, 5:29pm UTC](https://forums.sketchup.com/t/appobserver-onopenmodel-callback-called-twice/286522/1 "2024-08-21T17:29:29Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [August 21, 2024, 6:21pm UTC](https://forums.sketchup.com/t/appobserver-onopenmodel-callback-called-twice/286522/2 "2024-08-21T18:21:18Z")

</div>

This has been reported ( **3 years ago** ) in the official SketchUp APIs issue tracker:

- [SketchUp APIs issue : search “onOpenModel”](https://github.com/SketchUp/api-issue-tracker/issues?q=is%3Aopen+is%3Aissue+label%3A%22Ruby+API%22+label%3ASketchUp+onOpenModel)
