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

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s