DefinitionList.load() breaking Undo stack?

I’m loading a library of pre-built component definitions into my extension:

pathname = File.join(File.dirname(__FILE__), 'library.skp')

which works, but it injects a “Load Component” into the Sketchup Undo stack which I don’t really want the user to see, and it also seems to ‘swallow’ the next operation my extension does, which I have wrapped up with Sketchup.active_model.start_operation("Create Bent")Sketchup.active_model.commit_operation

After this first operation the Undo stack behaves as I expect, but nothing I’ve tried will separate the ‘Load Component’ and ‘Create Bent’ operations. I’ve tried putting the load inside my ‘Create Bent’, wrapping it in its own start_operation()...commit_operation(), and even setting the next_transparent = true or transparent = true parameters to start_operation().

Am I doing something wrong, or is this a known bug in Sketchup 2013?


SketchUp 2013 ? on Win7-64bit ? This is running under Ruby 1.8.6.

There have been massive changes to the undo stack and model operations engine since.
Not many of us even test under v2013 anymore, or remember what the major bugs were.
It’s no longer supported by Trimble, and will not work with the 3DW.
Why not update to a later version using Ruby 2.x ?

You’re loading the definitions into the model, which changes the model, so the load should be within an operation.
Definitions should not be loaded unless an instance is to be placed in the model.

Doing this can fire other coder’s observers, where they might say add an attribute. This could cause you issues.
Always test with all other plugins off, get things working then switch on plugins like Dynamic Components and retest. Switch on more, retest, etc.

Yes, 2013 on Win7-64 bit. I’ve now tried it on Sketchup 2017 and that Undo stack problem with definitions.load() has been fixed.

Is there no Sketchup bugs database available to extension developers so we can quickly search for known bugs, potential workarounds, etc? Searching the forum doesn’t always help.

I’m only loading definitions if my extension is about to place an instance. i.e., the user has chosen a specific operation that needs them.

And the load operation was wrapped inside a commit operation, it is just that under Sketchup 2013 that was breaking the naming of operations on the undo stack a bit, so I was hunting for a potential workaround. Since it works in 2017, I’ll just have to put up with the bug in 2013.

Unfortunately, no. The SketchUp developers have always kept their bug database private.

I’ve rewritten that part of my code now, and instead of loading a library of M12 bolts, nuts & washers, it just builds them on demand. Not only is it much easier to create bolts of a length to fit specific timbers, but it also halves the size of the extension! 121kb down to 67kb :slight_smile:

1 Like

This issue was fixed in SU2014

You can see it mentioned in the release notes: