rootPath + currentFrame

Discussion about scripting with Python
bmecohen
Posts: 28
Joined: Thu Sep 27, 2012 12:55 pm

rootPath + currentFrame

Postby bmecohen » Thu Oct 11, 2012 2:13 pm

Hello!

I am new in Python scripting and I would like to make a GUI form, to create a specific folder for exporting particle files and I have little problems.

Code: Select all

current_frame = scene.getCurrentFrame()
root_path = scene.getRootPath()


I want a structure: after a simulation frame was finished, get the name of the frame, and used it as a name for a file like:

Code: Select all

file = open( root_path + current_frame ".txt", "w")


The syntax check says an error in the line of file = open and I don't know how to get the root_path and current_frame correctly. I think it will be a integer to string problem or something.


bmecohen
Posts: 28
Joined: Thu Sep 27, 2012 12:55 pm

Re: rootPath + currentFrame

Postby bmecohen » Sat Oct 13, 2012 12:25 pm

I made the code, I missed some formatting. I post it maybe for a python rookie like me could use it.

The code is:

Code: Select all

currentFrame = scene.getCurrentFrame()
rootPath = scene.getRootPath()

file = open(str(rootPath)+"/export/"+str(currentFrame)+".txt", "w")

User avatar
jalixko
Posts: 72
Joined: Tue Jan 02, 2007 1:11 pm

Re: rootPath + currentFrame

Postby jalixko » Wed Nov 21, 2012 8:57 am

Have a look to this script that could solve your problem.
http://rfwisdom.wordpress.com/2010/08/0 ... ns-script/


Return to “Python-Scripting”

Who is online

Users browsing this forum: No registered users and 2 guests