THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/01/2012 at 13:46, xxxxxxxx wrote:
Just curious why setting the name of a selection tag is different from setting the name of a material tag
see WORKS - DOESNT WRK Comment
(Python conversion of Script by Steve Pedler - to take the name of a material and apply it to the selection and name of associated selection tag)
import c4d
from c4d.documents import GetActiveDocument
from c4d import BaseContainer
from c4d.gui import GeDialog
def main() :
c4d.CallCommand(13957);
doc = GetActiveDocument()
if doc is None:
return False
op = doc.GetActiveObject()
if op is None:
print 'No Object Selected'
return False
tag = op.GetFirstTag()
while tag:
bc = tag.GetDataInstance()
if tag.CheckType(c4d.Ttexture) :
matselname = bc.GetData(c4d.TEXTURETAG_RESTRICTION)
matname = tag[c4d.TEXTURETAG_MATERIAL].GetName()
seltag = op.GetFirstTag()
while seltag:
bc2 = seltag.GetDataInstance()
if seltag.GetName() == matselname:
bc.SetData(c4d.TEXTURETAG_RESTRICTION, matname)
seltag[c4d.ID_BASELIST_NAME] = matname # WORKS
# bc2.SetData(c4d.ID_BASELIST_NAME, matname) DOESNT!!!!
#seltag.SetName(matname) WORKS
seltag = seltag.GetNext()
tag = tag.GetNext()
c4d.EventAdd()
return True
main()