THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/08/2012 at 02:09, xxxxxxxx wrote:
I'm trying to write a script that watches a folder and looks for new C4D files. Once it finds a new file it should add the file to the render que. The code works fine in an external editor, however in C4D it doesn't work. When I run the script and add a new file to the watch folder, C4D hangs and I have to restart it.
Does anyone have a clue why? See the code below.
def watchFolder() :
before = os.listdir('/Users/blabla/watch folder')
after = os.listdir('/Users/blabla/watch folder')
newFiles = list(set(after)-set(before))
if len(newFiles) > 0:
before = after
def renderFile() :
for i in newFiles:
if i[-3:] =='c4d':
# then some code here to add the file to the renderque and start rendering
On 13/08/2012 at 03:27, xxxxxxxx wrote:
Of course it hangs, because you block the main thread. Put your code into a threaded environment.
For R13+, see the c4d.threading module which works afaik fine in the Script Manager. For R12, you'd need to write a plugin that uses the built-in threading module.