Change dimensions font color and style using ruby


Hi All,

If any possibility for change linear dimensions font color and style in SketchUp using ruby?

Siva S


Dimensions (with or without text) are drawing elements like a face or edge. So you assign a material with the desired color.


Hi @Aerilius,

I have placed the linear dimension’s are like using add_dimension_linear,
eg., Sketchup.active_model.entities.add_dimension_linear([50, 5, 0], [100, 5, 0], [0, 20, 0])


look the above image, i want to change the text color from black to other color. If have any possibility to change the color? Please let me know.


When you do programming, you want that everything is unambiguous and deterministic. Therefore you must always want to keep references to everything that you want to continue working with.
Out of the many entities in your SketchUp model, you do not want to take a random one and change its color without knowing whether it was the desired linear dimension.

Therefore you must keep a reference to the created linear dimension so that you can change its color subsequently.

# Do NOT call active_model more than once and only at the beginning of an operation, you want to be sure that you always work on the same model.
model = Sketchup.active_model
entities = model.entities
# …
linear_dimension = entities.add_dimension_linear([50, 5, 0], [100, 5, 0], [0, 20, 0])
linear_dimension.material = "chartreuse"
# Without a reference to the created dimension, you would not have been able to assign a color to it.

You can read the API documentation and pay attention to what methods return. When the signature says

then it means that it takes 3 parameters (whose type you find in the parameters section) and returns an object of type Sketchup::DimensionLinear (after the ).


Thanks @Aerilius, It’s working fine :slight_smile:


As Aerilius told you, …

Yes, for font color via Ruby (assigning a material.)

No, as of yet, for font style via the Ruby API.

But font styles are exposed via the C API, so they might be changed if you know C and know how to create a Ruby C extension for SketchUp.