How To Set Dimension Text/Value?

Hi @michaelvollrath, below seems to do it:

#! python 2
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def dim_filter(rhino_object, geometry, component_index):
    return isinstance(rhino_object, Rhino.DocObjects.DimensionObject)

def EditDimensionText():
    dim_id = rs.GetObject("Select Dimension", 512, True, True, dim_filter)
    if not dim_id: return
    
    dim_obj = rs.coercerhinoobject(dim_id, True)
    old_val = dim_obj.AnnotationGeometry.PlainText 
    new_val = rs.GetString("Enter new value", old_val, ["ComputedValue"])
    if not new_val: return
    
    if new_val == "ComputedValue": new_val = "<>"
    
    dim_obj.AnnotationGeometry.PlainText = new_val
    dim_obj.CommitChanges()

EditDimensionText()

To reset it to the computed value <> click on the option ComputedValue.

_
c.

1 Like