THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/08/2011 at 02:15, xxxxxxxx wrote:
Ok guys, so i am writing a script using your code which basically puts a multi-cam project to a renderfarm with one click. IT makes x number project folders with each c4d containing different active cameras (using Xpresso).
I am just getting into the loop part to change the selected camera BEFORE it calls the SaveProject() function which Nux was so kind to provide. The script at the moment creates the folders correctly, but it is not changing the user data which in turn should be changing the active camera. I am sure its a simple syntax error and the way im getting the user data. Help? The User data ID which controls the selected camera is #17.
Thanks. PS. once this is sorted id like to be able to get the filename and renderfarm path dynamically from a string/dir user data. This is easy i suspect once someone clues me in on how i have skrewed up the currect code...
Thanks guys.
import c4d
from c4d.documents import LoadDocument, SaveDocument, GetActiveDocument, InsertBaseDocument
from os.path import abspath, dirname, split, join, exists, basename, isabs
from os import makedirs, mkdir
from shutil import copytree, copy
def SaveProject(doc, path) :
pah = abspath(path)
ndir_, name = split(path)
ndir_ = join(ndir_, name[:name.rfind('.')])
if not exists(ndir_) :
makedirs(ndir_)
new_illum = join(ndir_, 'illum')
new_tex = join(ndir_, 'tex')
dir_ = doc.GetDocumentPath()
if dir_:
illum = join(dir_, 'illum')
if exists(illum) :
copytree(illum, new_illum)
tex = join(dir_, 'tex')
if exists(tex) :
copytree(tex, new_tex)
for i, texture in doc.GetAllTextures() :
if not isabs(texture) : continue
copy(texture, join(new_tex, basename(texture)))
SaveDocument(doc, join(ndir_, name), 0, c4d.FORMAT_C4DEXPORT)
return True
# example:
#SaveProject(doc, 'C:\\foo.c4d')
def SaveLoop() :
doc = GetActiveDocument()
selectedcam = op[c4d.ID_USERDATA, 17] # id: the id of the userdata entry
for i in xrange(8) :
# ... Change whatever you want
selectedcam = i
c4d.EventAdd()
SaveProject(doc, r'D:\Scene_cam0' + str(i) + '.c4d')
SaveLoop()