[BUG] page attribute issue

Running the following code in the SU builtin ruby console, then the software crash

# plugin add page & set attribute
model = Sketchup.active_model
model.start_operation('add page & set attribute')
page = model.pages.add(page)
page.set_attribute('dict', 'key', 'value') # cause bug

# user undo and quit

repeat but close issue


I can reproduce this. (By the way, the ideal place to log API bugs/issues is at our GitHub tracker: Issues · SketchUp/api-issue-tracker · GitHub)

This issue stems from that adding/removing pages (scenes) are not undoable. Those actions are not recorded in the undo manager.

However, since a Page is an Entity it exposes the ability to set attributes - which is an undoable operation. This was done a long time ago, way before my time, so I can only guess - but I don’t think the original implementers considered that scenario.

I’ll log this in our issue tracker.

Meanwhile, I don’t see an easy workaround to avoid the crash. You could try to store the attributes on the model instead. And use page name + page id as a way to match the attributes with that pages you want to associate it with. Since the names change you probably want to use the entityID as a backup (though note that it changes between sessions.)

1 Like

I get the temp solution(find page by name). Thanks.
By the way, if the new bug were found, I would commited the bug at the github tracker.


Wouldn’t the persistent_id work for this, if the extension only supports SU 2018 and later?

Yes, that’s correct, for SU2018 you can use persistent ID which would be much more reliable to sync up your entity references.