How to get text/dim/leader actual text and not the result of a "formula"?

R5 Rhino.DimensionUserText() would get the actual text, in R6 it’s getting the text field result.

It broke bunch of our scripts and I need to fix it ASAP for both Python and RhinoScript.

I need this:
%<CurveLength(“4e840118-cd97-442c-b404-ac6cc4759f93”)>%
not
123.456

not sure how you get that in Rhino 5, I just get the same result in 5 and 6, but to get what you want in Rhino 6:

import rhinoscriptsyntax as rs
obj = rs.GetObject("select dimension with user text")
obj = rs.coercerhinoobject(obj)
print obj.AnnotationGeometry.TextFormula

note: this code doesn’t work in Rhino 5

1 Like

Thanks! R5 works as expected. Do you have any idea on how to do it in R6 RhinoScript?

@dale

As far as I can see there is no rhinoscript method to this, but do you really need it? You can do the same in python and much more…

I’m revising all the R5 RhinoScripts to work in R6 just to save time, 'cause there’s actual work to do. I guess I’ll have to rewrite some scripts in python. I’m learning it as I go too.

Like at the moment I can’t make this work for some reason:
sc.doc.Objects.Find(dim).AnnotationGeometry.DimensionStyle.ClearAllFieldOverrides
dim.CommitChanges()

what does it need to do?

Reset all dim style field overrides of a dimension to dim style defaults.

It’s a bit vague but this seems to work:

from Rhino import *
dims = list(RhinoDoc.ActiveDoc.Objects.FindByObjectType(DocObjects.ObjectType.Annotation))
for dim in dims:
    dim.AnnotationGeometry.DimensionStyleId = dim.AnnotationGeometry.DimensionStyleId
    dim.CommitChanges()

basically the dim.AnnotationGeometry.DimensionStyleId returns the id of the dimension parent definition. and assigning it to itself seems to reset it to the defaults…

1 Like