Here is a script which:
- creates a copy of the current document
- removes all of its texture tags
- groups everything under a single null
- assigns a cubic-projection texture tag to the null
- saves the copy to a .c4d file
You can then open the saved copy and render. Of course, when using this method, it's not actually necessary to use the override material at all, since everything is now using a single texture tag -- just apply your desired material to that, and adjust the projection as desired.
Code: Select allimport c4d
def kill_tags(o, t):
while o and o.GetTag(t):
o.KillTag(t)
def remove_tags(o):
while o:
kill_tags(o, c4d.Ttexture)
#kill_tags(o, c4d.Tpolygonselection)
remove_tags(o.GetDown())
o = o.GetNext()
def group_objects(d):
p = None
o = d.GetFirstObject()
n = c4d.BaseObject(c4d.Onull)
d.InsertObject(n)
while o:
t = o.GetNext()
if p:
o.InsertAfter(p)
else:
o.InsertUnder(n)
p = o
o = t
def apply_override(d):
m = c4d.BaseMaterial(c4d.Mmaterial)
m.SetName('Override')
d.InsertMaterial(m)
n = d.GetFirstObject()
t = n.MakeTag(c4d.Ttexture)
t.SetMaterial(m)
t[c4d.TEXTURETAG_PROJECTION] = 3;
def main():
d = c4d.documents.GetActiveDocument().GetClone()
remove_tags(d.GetFirstObject())
group_objects(d)
apply_override(d)
c4d.documents.SaveDocument(d, 'clone.c4d', saveflags=c4d.SAVEDOCUMENTFLAGS_0, format=c4d.FORMAT_C4DEXPORT)
if __name__=='__main__':
main()
To run the script, open Script > Script Manager, make sure you have selected the Python (as opposed to C.O.F.F.E.E) tab, click File > New, and paste in the script. You can then use File > Save As to save it for later, and/or create a toolbar button for it by clicking the "Shortcut..." button near the bottom-right corner of the Script Manager.