Bug Report: LinearDimension Custom Text Font Size Resets to Document Default on Second Click

Environment

  • SketchUp / LayOut Ruby API

  • Affected class: Layout::LinearDimension

  • Platform: Windods Sketchup2026

Summary

When creating a Layout::LinearDimension entity via the API with a custom text and a custom font size, the font size visually resets to the document’s default dimension font size after the user clicks the dimension once (to select it), deselects it, and then clicks it a second time. All other style properties (e.g. text color, stroke color, arrow type) remain correct and are not affected.

Steps to Reproduce

  1. Create a Layout::LinearDimension entity via the API.

  2. Set a custom text using entity.custom_text = true and entity.text = formatted_text.

  3. Set a custom font size via the dimension’s style:

def draw_dimension(pt1, pt2, vector, text)
  pt3 = pt1 + vector
  pt4 = pt2 + vector
  pts = [pt1, pt2, pt3, pt4].map do |pt|
    @skp_model.model_to_paper_point(pt)
  end
  height = resolve_height(pts[0], pts[1], pts[0].vector_to(pts[2]))
  entity = Layout::LinearDimension.new(pts[0], pts[1], height)
  entity.leader_line_type = Layout::LinearDimension::LEADER_LINE_TYPE_HIDDEN
  entity.start_offset_length = 0
  entity.end_offset_length = 0
  red = Sketchup::Color.new(255, 0, 0, 255)
  formatted_text = entity.text
  formatted_text.plain_text = text
  entity.text = formatted_text
  entity.custom_text = true
  @layout_doc.add_entity(entity, @layout_layer, @layout_page)
  apply_dim_style(entity, red, DIMENSION_FONT_SIZE)
end

def apply_dim_style(dim, color, font_size)
  style = dim.style

  dl = style.get_sub_style(Layout::Style::DIMENSION_LINE)
  dl.stroke_color     = color
  dl.start_arrow_type = Layout::Style::ARROW_FILLED_CIRCLE
  dl.end_arrow_type   = Layout::Style::ARROW_FILLED_CIRCLE
  dl.start_arrow_size = 0.6
  dl.end_arrow_size   = 0.6
  dl.stroke_width     = 0.4
  style.set_sub_style(Layout::Style::DIMENSION_LINE, dl)

  [
    Layout::Style::DIMENSION_START_EXTENSION_LINE,
    Layout::Style::DIMENSION_END_EXTENSION_LINE
  ].each do |k|
    sub = style.get_sub_style(k)
    sub.stroke_color = color
    sub.stroke_width = 0.4
    style.set_sub_style(k, sub)
  end

  ts = style.get_sub_style(Layout::Style::DIMENSION_TEXT)
  ts.font_size      = font_size
  ts.text_color     = color
  ts.text_alignment = Layout::Style::ALIGN_CENTER
  style.set_sub_style(Layout::Style::DIMENSION_TEXT, ts)

  style.font_size  = font_size   # also set on top-level style
  style.text_color = color

  style.set_dimension_units(Layout::Style::DECIMAL_MILLIMETERS, 1.0)
  dim.style = style
end

  1. Save and open the .layout file.

  2. Click the dimension once to select it, then click elsewhere to deselect.

  3. Click the dimension a second time.

Expected Behavior

The font size remains at the value set via the API (e.g. 5.0) after the second click.

Actual Behavior

The font size resets to the document’s default dimension font size (in our case 8.0). All other style attributes (text color, stroke color, arrow type, stroke width, etc.) are not affected and remain correct.

Diagnostic Results

Immediately after API writes, reading back all values confirms everything is correctly set:

custom_text: true
dim.style font_size: 5.0
DIMENSION_TEXT font_size: 5.0
DIMENSION_TEXT text_color: Color(255, 0, 0, 255)
FormattedText plain_text: 470
FormattedText style font_size: 5.0
FormattedText style text_color: Color(255, 0, 0, 255)

So the issue is not in the write phase. The font size is correctly stored in the entity’s style immediately after creation. It only resets when the user interacts with the dimension for the second time in the LayOut UI.

Additional Observations

  • The bug only triggers on the second click (select → deselect → select again). The first click shows the correct font size.

  • Manually setting the font size in LayOut’s text style panel after the fact permanently fixes the issue for that entity — it never resets again after the manual edit.

  • Different dimensions in the same document are created with different font sizes (we cannot simply change the document-level default style as a workaround).

  • The bug is specific to font_size. Other text style properties such as text_color are not affected by this reset behavior.

Question

Is there a way via the API to mark a dimension’s font size as “explicitly set” (equivalent to what LayOut does internally when the user manually edits it in the UI), so that it is not overwritten by the document default on subsequent interactions?

Alternatively, is this a known bug in the LayOut API?

I haven’t delved into the topic… but I guess, this one can be related: Layout::Document#add_entity overwrites preset style properties · Issue #805 · SketchUp/api-issue-tracker

( BTW, Usaully better to report API bugs there.
API Issue Tracker on GitHub. )