Hi:
After a trial run, the script was tested successfully. By setting the name suffix of Python Tag, the problem of repeated running of Tag can be solved.
Taking c4d.DIRTYFLAGS_SELECT as an example, if the point, line, and surface selections change, it will execute, otherwise it won't.
The Python script code is as follows:
import c4d
#e-mail: xiuziye@qq.com
def main():
Name = op.GetName()
Objects = op.GetObject()
Changed = Objects.GetDirty(c4d.DIRTYFLAGS_SELECT)
Text = ["xit" + str(Changed)[-1]]
if str(Name).count(Text[0][:-1]) != 0 :
if str(Name).find(Text[0][:-1]) != str(Name).rfind(Text[0][:-1]) :
if str(Name)[str(Name).rfind(Text[0][:-1]):] == Text[0] :
if str(Name).find(Text[0][:-1]) <= 0:
#Do not execute, exit the program.
print ("Does not perform.")
op.SetName(str(Text[0]))
return
else:
#Do not execute, exit the program.
op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0]))
print ("Does not perform.")
return
else:
if str(Name).find(Text[0][:-1]) <= 0:
op.SetName(str(Text[0]))
print ("Perform.")
else:
op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0]))
print ("Perform.")
else:
if str(Name)[str(Name).rfind(Text[0][:-1]):] == Text[0] :
#Do not execute, exit the program.
print ("Does not perform.")
return
else:
op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0]))
print ("Perform.")
else:
print ("Perform.")
op.SetName(str(Name) + str(Text[0]))
print ("pass")
#The next thing to execute.