Opening a Layout file using the Ruby API is Slow

I’m developing a plugin that opens and then appends a page to an existing Layout file. As the Layout file gets larger, it takes longer and longer to execute the script. Has anyone else experienced this, or have any tips to improve performance? CB.

This was tested on SU23, and on my windows machine, it took 13 seconds to open a 45-page LO doc.

It has happened in the past for other API collections.

What is the amount of time involved?

On my laptop at home, it’s about 45 seconds to load the file, then another 10 seconds to save it. It’s faster on the desktop at work, but still drags. The LO doc is 37 pages, although they are not complex. The file is about 5.8MB. The LO application can load the file in about half that time (not very impressive either).

Um … I was asking about the time increase when adding a page to the document with Ruby, as indicated in the opening post.

55 seconds. From my console output, I can see that 45 if those are to load and append my page, and another 10 to save it again.

ping @adam

Some more detail from my (much) faster desktop machine:

12:13:12:018 - Before   # this is a 45-page LO doc
12:13:25:381 - After    # it takes 13 seconds to open the file
12:13:25:383 - Before scanning for existing page
12:13:25:384 - After scanning for existing page
12:13:27:565 - Before document save              # my code to generate the new page takes 2 seconds
12:13:30:507 - After document save               # saving the doc takes 3 seconds.

So it’s not as bad as the laptop, but still long enough for my users to wonder what’s going on.

Okay, again, your topic title and first post indicated that “appending a page” was slow.

But, the additional details show it is only 2 seconds (give or take). You have not shown that the page append time is increasing with each page.

I submit that your topic title is “off the mark” and the original report is vague. I suggest editing both to make it clear that the problem lies with file loading time.

Agreed. Until I broke it down, I wasn’t sure where the delay was. Still hope something can be done to improve performance of the file loading time. For now, I’ll have to settle for:

Sketchup.status_text = "A page is being appended to the Layout doc (this can take a while)..."
1 Like

Any difference in the version ? 2024 or previous versions ?

You do realize that .layout files are zipped archives of XML and associated resources (image files, .skp files, etc.,) ? So, they must be unzipped, parsed, etc., each time they are opened.

I haven’t tested with any other versions. No, I was not aware that’s how things were being stored. So perhaps there’s hope then for a more efficient method in the future.

You never actually specified what version you did test on.

Layout 23

Okay, but please update the original report with version and time information.