Environment
-
SketchUp / LayOut Ruby API
-
Affected class:
Layout::LinearDimension -
Platform: Windows 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 a hardcoded application-level default (8pt) after the user clicks the dimension once (to select it), deselects it, and then clicks it a second time. This reset value is neither the font size set via the API, nor the font size defined in the document template — it appears to be an internal LayOut application default. All other style properties (e.g. text color, stroke color, arrow type) remain correct and are not affected.
Steps to Reproduce
-
Create a
Layout::LinearDimensionentity via the API. -
Set a custom text using
entity.custom_text = trueandentity.text = formatted_text. -
Set a custom font size (e.g.
5.0) 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
-
Save and open the
.layoutfile. -
Click the dimension once to select it, then click elsewhere to deselect.
-
Click the dimension a second time.
Expected Behavior
The font size remains at the value set via the API (5.0pt) after the second click.
Actual Behavior
The font size resets to 8.0pt. All other style attributes (text color, stroke color, arrow type, stroke width, etc.) are not affected and remain correct.
Key Observation: The Reset Value Is Neither the API Value Nor the Template Default
This is the most important clue:
| Source | Font Size |
|---|---|
| API-set value | 5pt |
| Document template default | 10pt |
| Value after second click | 8pt |
The reset value of 8pt matches none of the above. It appears to be a hardcoded internal default within the LayOut application itself, unrelated to either the entity style or the document/template style.
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)
The issue is not in the write phase. The font size is correctly stored 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 intentionally created with different font sizes, so changing the document-level default style is not a viable workaround.
-
The bug is specific to
font_size. Other text style properties such astext_colorare not affected by this reset behavior, even though they are set through the same code path. -
The reset value of 8pt is consistent across all affected dimensions regardless of their individual API-set font sizes.
-
The bug is only in windows platform, macos has no such bug.
Question
It appears that when a user manually sets the font size in the LayOut UI, LayOut internally marks the entity’s font size as “explicitly overridden,” preventing it from being reset by the application default on subsequent interactions. Is there a way to achieve the same effect via the API — i.e., to mark the font size as explicitly set so that LayOut treats it the same way as a manual user edit?
Alternatively, is this a known bug in the LayOut API where font_size set via Style on a LinearDimension with custom_text = true is not correctly persisted across UI interactions?