On 11/06/2016 at 12:40, xxxxxxxx wrote:
Hi,
Is there a way to check if a texture tag is pointing to a deleted material?
If you delete the material. The texture tag still thinks it's there for some strange reason.
I did find a way to do it in Evil Mad Scientist mode. :smiling_imp:
But is there an "official" way to do this?
#When deleting the material. The tag does not automatically update it's container to reflect that!! Why!!??
#This example checks if the texture tag has a material assigned to it by looking at the icon's coordinates
#If the icon values are not 0 & 0. Then there is no material assigned to the texture tag
import c4d
def main() :
texTag = op.GetTag(c4d.Ttexture)
#Get the icon on the tag to see if it's coords are used to display the X icon(no material)
icon = texTag.GetIcon()
iconX = icon['x']
iconY = icon['y']
#print iconX, " ", iconY
#1010 is the id in the texture tag's container that links to it's material(if any)
#But it does not reset itself to None if the user deletes the material! why??
#This code resets the tag's material container entry to be None. And sets the name value to "None"
bc = texTag.GetData()
if iconX != 0 and iconY != 0:
bc[1010] = None
mat = texTag.GetMaterial() #<--Technically this should be null. But the tag hangs on to the deleted material's name!!!
mat.SetName("None")
#Prints the material's name if there is a material assigned to the texture tag
#Or None. If the material was deleted
print texTag.GetMaterial().GetName()
c4d.EventAdd()
if __name__=='__main__':
main()
-ScottA