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",

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, "")

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s