Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/06/2012 at 09:36, xxxxxxxx wrote:
I am beginning to think I do not quite understand the relation between cinema 4d and python. I have a python tag with a some simple code (see below). What I want to achieve is store data on frame x and use in frame x+1.
For frame 0 it is ok, but for other frames I get the message "referenced before assignment". I do understand the message and why it is given, but it tells me that the code is executed every frame and the variables are initialized every time.
I can use userdata or the BaseContainer, that solves my issues, but I would like to understand. I also tried global variables, but that didn't help either.
What to do?
def main() :
print "\n----------\n"
frame = doc.GetTime().GetFrame(doc.GetFps()) if (frame ==0) : varx = 0 else: varx = varx + frame
print "varx: ", varx
On 08/06/2012 at 09:43, xxxxxxxx wrote:
Sorry, I did not search the forum before asking.
The solution is simple. Just init the variable outside main and define it as global within main.
varx=-1
global varx