Scripting the creation of text objects


Here’s a little Python snippet that creates a bunch of text objects, one for each item in a list. Note the handling of multiple lines (elements in triple quotes).

names = ["Test", """Coming
Soon""", "XSI",
"""one
two
THREE""", "SUMATRA"]

for n in names:
                text = Application.CreateMeshText("CurveListToSolidMeshForText", "siPersistentOperation")
                if n.find( "\n" ):
                                n = n.replace( "\n", "\\par\r\n" )
                                Application.SetValue(str(text) + ".crvlist.TextToCurveList.text.singleline", 0, "")
                                
                Application.SetValue(str(text) + ".crvlist.TextToCurveList.text.text", "%s%s%s" % ("_RTF_{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\froman\\fcharset0 Arial;}}\r\n\\viewkind4\\uc1\\pard\\lang1033\\f0\\fs20 ", n, "\\par\r\n}\r\n"), "")
                Application.SetValue(str(text) + ".extrudelength", 1, "")