Document identifier for Mac's multi document interface

model
session
identifier

#1

I know this has been discussed before at SketchUcation but I just find it.

I need an identifier for each open model to prevent tool settings from getting mixed up when the same tool is used is multiple models on Mac. It cannot be the persistent ID since the user may have two versions of the same model open at the same time. It needs to be a unique identifier on a model session basis, not model basis.

The Sketchup::Model object has previously been known to randomly change and haven’t been a reliable identifier. According to the thread at SketchUcation that I’ve been searching for the whole evening “model.definitions.object_id” was the most reliable method, but that was several years ago and has maybe changed.

Does anyone know what is best practice for this today?


#2

Since that time, they added a new callback to the AppObserver that only fires on the Mac.
http://ruby.sketchup.com/Sketchup/AppObserver.html#onActivateModel-instance_method


#3

I don’t really know how I would use the AppObserver for this. I don’t want to purge the data when the model changes, just have it stored in a Hash indexed by the model.


#4

The new callback fires (only on Mac,) when the user activates a different model document window.
Unfortunately, they did not give us an onBeforeWindowSwitch callback.

As you might know,… I had long had a request in for a model collection. However, many of the API methods are written “under the covers” to assume the model object receiver for methods is the active model. Calling instance methods upon non-active model objects would sometimes work, other times just act on the active model, and they said perhaps other times crash SketchUp. So, they just could not give us this collection, for fear that having references to non-active model objects would encourage coders to call methods upon them.


#5

This topic was automatically closed after 91 days. New replies are no longer allowed.