Model not modified when I add or rename scene (Ruby API)

When I add a new scene or rename the existing scene model not get modified in Ruby Console. But I close SketchUp it asks to save the model. Is there any other way to identify the model is modified?

Ruby Console code

What version of SketchUp are you reporting this for ?

It is a known bug that adding scenes through the Ruby console bypasses the undo stack (no new operation that can be undone). It could be related that the model is not marked as dirty/modified.

If your extension really requires to know about this specific property, you could register a PagesObserver that will notify your extension and set a variable @modified to true.

Sketchup 2018

This is not specific to the Ruby API. Scene changes are not recorded to the undo stack. It appears to be a design choice but I don’t know what the reasoning behind it is.

@Bryceosaurus, you’ve been around since the @Last days, right? Could you spread some light on this?

1 Like

Sorry for the delay. +@ChrisFullmer.

I think dirtying the file and saving something to the undo stack are not 1:1. Looks like certain manual scene edits do dirty the file but are not saved to the undo stack. I suspect that is because scenes don’t really change the model by adding/changing geometry. The are more like different states of a model. I don’t recall a explicit decision to exclude scenes from undo but it makes sense to me that they are not part of undo. Maybe Chris knows more?

Regarding when a file is regarded as modified maybe there is a platform difference here. On Windows I’ve never seen a SU file be regarded modified without something being written to the undo stack or vice versa. If I’m not mistaken the modified state is even reset if you undo all the way back to an empty stack.

Regarding what is a recorded operation there is no universal standard. Some programs include selection changes (to my annoyance). In SketchUp it makes a lot of sense that view changes (renderingOptions) are not recorded as they are often temporary and easy to reset. You may need to toggle hidden geometry just for evaluating the undo stack. Committing such changes to a style and overriding its existing properties, as well as altering a scene would make sense to me to be undoable. There is probably some reasoning behind this choice that I’m not aware of though.