1

I'm trying to make a little script for batch rending for maya and every time I have this error at the line for i in xrange((startFrame)+"," +(endFrame) + int(1)): : in Batch # TypeError: coercing to Unicode: need string or buffer, int found

the code :

def Batch(ignore): # Settings startFrame = cmds.textField (myStart, query=True, text=True) endFrame = cmds.textField (myEnd, query=True, text=True) Camera = cmds.textField (myCamera,query=True, text=True) for i in xrange((startFrame)+"," +(endFrame) + int(1)): maya.cmds.currentTime(i) mel.eval('execRmanMenuItem("Render");') editor = 'renderView' 

I'll be very thankful if someone could help me.

2
  • for i in xrange(startFrame, endFrame + 1): ?? Commented May 26, 2018 at 9:32
  • try .format() with {} that should coerce a type to string. if you're on python 3.6 f-strings do the same as .format() method. + are never good on strings Commented May 26, 2018 at 9:34

1 Answer 1

1

Python xrange takes ints as parameters not strings,

This should solve it:

for i in xrange(int(startFrame), int(endFrame)+1): ... 
Sign up to request clarification or add additional context in comments.

1 Comment

@iobs, consider accepting the answer. Happy coding :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.