Modifying leader text through the Ruby API

I was trying to find information about accessing leader text attributes (font, style (bold, italic, etc.), size, etc.) through the Ruby API, but I can’t find anything posted recently about it. Do we know if there are any plans to add this capability to the Ruby API anytime soon?

I have noticed that when a leader text entity is selected, there is a button in the Entity Info GUI that allows you to make the changes:

And I also found in this post that you can change the default font, size, style, etc. for leader text using the Model Info window, so I will be able to do what I need to do for now, but I am interested in being able to modify these attributes via the Ruby API, as I am sure many others are.


Lists all of the available methods for Text [2d].

These methods do include ways to get/set the text, its location, leader/arrowhead-type etc.

But other things like font, height, style, bold/italic etc are not available - despite many requests over the years…

You have more control with 3dText…

1 Like

As TIG says, there is no way through ruby to control font characteristics for text defaults or for individual text elements.
However there is a long and laborious workaround that I used for my 2DXY SiteSurvey extension. It’s described in the first section of this video:

Here are the steps I used:

  1. I determined that text heights between 1 foot and 30 foot in one foot increments were adequate for my purposes.
  2. In SU I opened a new skp file and added a single leader text element at the origin and 1 foot high.
  3. Purged all scenes, materials, layers, styles, component definitions.
  4. Saved AS text1.skp in resources folder of the extension using oldest SU version I intend to support.
  5. Changed Height to 2 feet and saved that and so on until I have 30 skp files.
    (I judged that the same 30 files would work for metric users.)
    (All texts are the same font and style otherwise you have thousands of files.)

In ruby for an individual text you want to add.

  1. Determine the text content, location and height you want.
  2. Load the file you want using definitions.load.
  3. Add an instance of this definition using entities.instance_add
  4. Explode the instance.
  5. Delete the definition using entities_clear.
  6. Assign the location using text.point
  7. Change the text content.

In my case I duplicated all of this also for dimension text.

What fun!!!:wink:


This functionality has been implemented in the C API.

The C API parity with Ruby API is one of the major goals of the early phase for the C API project, as noted in the Release Notes. (The font functions were implemented likely because they may have already been there in the old C++ SDK. I really don’t feel like spending time looking through old C++ API docs right now, and it’s not that important why the functions are there.)

Trimble cannot make public statements about future product plans, as the company is publicly traded. (It’s a legal no-no called “insider information”.)

I wouldn’t be surprised if Ruby API exposure of these C-side functions occurs within a version cycle or two … (give or take some tolerance.) As a policy (from past history since v2013) the SketchUp Team only wants to introduce new functionality at major releases.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.