Is it possible to Change default dimension attributes from Layout Ruby API?


As I can see, it’s possible to change specific dimension attributes (like leader type, font size, etc…) when we create a .layout file from Ruby API.

But is it possible to change the default attributes, to permit user to create other dimensions from Layout with the same style ?

Have a nice day :sunny:

I’m afraid, you cant…

Class: Layout::Style — SketchUp Ruby API Documentation

… The Document maintains a default style for various types of Entitys, and it is possible to apply the style of one entity to another. Style objects are transient and do not belong to a Document.…”


Ok, but it’s certainly stored somewhere in the layout file, because it doesn’t use the same defaults as when I create a new file directly from Layout … :thinking:

I think you can change the default by changing the active style then saving the file and using it as a template.

See discussion where I note that there is no Layout::Styles collection in the API:

In order to users to use a preset style there would have to be a named style feature as part of LayOut.

Can styled dimensions be saved as scraps and reused ?

Hi Dan,
You would say to do it manually in Layout and use the template file instead of creating a new one ?

Yes, I believe it is the only way as the API does not expose direct access to the document’s default entity styles.

However, I have not tried this in quite a while. So test. I believe manually this would change the style. But I do not know about afterward creating entities with the API.

If not, please open a request issue for API access to the styles in the GitHub API tracker. Having named styles would be a bonus.

Currently, a programmer would need to write their own style collection mechanism (hashes of style properties) and a factory creation method for every Layout::Entity class that applies their chosen style from their private collection after the object was created and added to the document.

Unfortunately if I open a layout template file, changing document unit doesn’t change default dimension unit and unit format …

Try logging this as a bug and see what the response is from Sketchup Team.

The layout file format is indeed a zip file, and I believe the relevant information is stored in a file named styleManager.xml.
You can change the file extension from .layout to .zip and extract its contents to check.


Interesting, I will check that. Thank you @curic4su !

Hi @curic4su, may be stupid question, but do you have a tip to parse zip file in ruby ?
Because as far as I can try require "zip" to load Ruby Zip lib doesn’t work anymore on SketchUp 2023.

Zip is not a library available by default in SketchUp, other SketchUp versions you can use may be someone who installed it through Gem.install (you can try this).
The best way is to download the source code of the zip library and wrap it into your namespace to avoid conflicts.

1 Like

Boris, here’s an example of opening and editing a layout file that was from years ago. It might save you some time.

layout_check_for_nans.rb (4.3 KB)


Thank you @sWilliams !