> > float $pos[]=particleShape1.worldPosition; > > > > setAttr ("heartPP_1_"+particleShape1.particleId+".tx") $pos[0]; > > > > setAttr ("heartPP_1_"+particleShape1.particleId+".ty") $pos[1]; > > > > setAttr ("heartPP_1_"+particleShape1.particleId+".tz") $pos[2]; > > """ > > dynExpression (p, s=expRuntime, rad=1) #generate the expression > > > > Then maya errors out, however if I pass maya an 'escaped' version: > > > > expRuntime=""" > > float $pos[]=particleShape1.worldPosition;\nsetAttr > > (\"heartPP_1_\"+particleShape1.particleId+\".tx\") $pos[0];\nsetAttr > > (\"heartPP_1_\"+particleShape1.particleId+\".ty\") $pos[1];\nsetAttr > > (\"heartPP_1_\"+particleShape1.particleId+\".tz\") $pos[2]; """ > > > > Then all is well. My question is, is there any way to convert the first > > variable example to the second? It's a lot easier to type and on the > eye. > > Except for the doble-space on the first version, \n is the line separator > on both, so I'll ignore them. > """one > two""" > is the same thing as "one\ntwo" (even on Windows). The only remaining > difference that I see is " -> \" > > def mayaquote(text): > return text.replace('"', '\\"') >
Thanks, this will work great. I was just wondering if there was an automatic 'string to escaped text' type function. Otherwise I'd have to build parsing for all chars that could cause a wobbly, but these may be few, so not too much of an issue. -- http://mail.python.org/mailman/listinfo/python-list