On 10/05/2018 at 08:11, xxxxxxxx wrote:
Hi, thanks to MaximeA i've been able to achieve the first part of a little script i wanted to make to generate an UVW tag and rename it with a specific name. Now i would like to change the order of the different tags that my object contains.
Let's say i have a polygon object with an UVW and a material tag, then i create the second UVW tag with my script. C4D adds this third tag on the left position of the list. I would like to recover the first original uvw tag and place it after my material on the list (originally, it is just before, on its left).
And as for the first part of this project, i can't find anything on the documentation about such an action. So, is it possible and which way should i take to achieve this?
Thanxs a lot
Nico
My original code
import c4d
from c4d import documents, plugins
from c4d import gui
#Welcome to the world of Python
def main() :
doc = c4d.documents.GetActiveDocument()
obj = doc.GetActiveObject()
if obj is None:
gui.MessageDialog('Select an object first')
return
tags = obj.GetTags()
matTag = obj.GetTag(c4d.Ttexture)
if matTag is None:
gui.MessageDialog('Insert a material first')
matTag[c4d.TEXTURETAG_PROJECTION] = c4d.TEXTURETAG_PROJECTION_CUBIC
uvwTag = c4d.utils.GenerateUVW(obj, obj.GetMg(), matTag, obj.GetMg())
uvwTag.SetName("CUBIC")
newName = uvwTag.GetName()
finalName = gui.RenameDialog(newName)
uvwTag.SetName(finalName)
obj.InsertTag(uvwTag)
matTag[c4d.TEXTURETAG_PROJECTION] = c4d.TEXTURETAG_PROJECTION_UVW
c4d.EventAdd();
if __name__=='__main__':
main()