Textfield formulas with python script not updating

python

#1

I wrote a python script to import text into textfields, including text formulas. Essentially:
rs.AddText("%<blockinstancecount(""+line.rstrip()+"")>%",…)

It seems Rhino doesn’t evaluate the inserted formula, it displays the full string as text.
Only after I manually modify the text the formula is evaluated.

Is this a bug or am I missing something?

Thanks


(Pascal Golay) #2

Hello - here’s an example of how to make that work, if I unde\rstand the question:

        text = "%<objectname(" + chr(34) + str(id) + chr(34) + ")>%"
        
        X = rs.AddText(" ", pt, height)
        
        textObj= sc.doc.Objects.Find(X)
        textObj.Geometry.TextFormula = text
        
        sc.doc.Objects.Replace(X, textObj.Geometry)

#3

That resolved it. Thank you very much.

I didn’t realize there are separate fields for Text Value and Text Formula.

It all makes sense now.