Python – Set Linear Dimension Text Inline (Rhino 8)

Hello,

In Rhino 8 (SR16), using Python in the ScriptEditor, how can I:

  • Select an existing linear dimension

  • Set its text to inline, positioned inside the dimension line, between the arrowheads

Is there a RhinoCommon property or method to change this text position via Python?

Thanks.

Hi @Daniel_Senff, try below script:

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

def DoSomething():

    dim_id = rs.GetObject("Select Dimension", rs.filter.annotation, True)
    if not dim_id: return
    
    dim_obj = rs.coercerhinoobject(dim_id, True, True)
    if not isinstance(dim_obj, Rhino.DocObjects.DimensionObject): return
    
    s = Rhino.DocObjects.DimensionStyle()
    s.CopyFrom(dim_obj.Geometry.DimensionStyle)
    s.DimTextLocation = Rhino.DocObjects.DimensionStyle.TextLocation.InDimLine
    
    dim_obj.Geometry.SetOverrideDimStyle(s)
    dim_obj.CommitChanges()
    
DoSomething()

_

c.

The code worked perfectly :+1:

Thank you very much for the help — I really appreciate it!