# Texture Tag Coordinate Rotation Help

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 05/06/2012 at 10:50, xxxxxxxx wrote:

Hello friends,

I am completely new to python scripting.

I am writing a script in c4d which allows me to apply materials randomly to a selection of objects and set the texture tag's rotation coordinates to random incrementals of 90 degrees.

I was able to figure out how to apply random materials to the selected objects however when i go to change the rotation values of the texture tags on the objects.... it is giving me unexpected results.

The resulting rotation numbers for X axis are very large like 10313.24 ° or, -5156.62 °; they should be 90, -90, 180, or 0.

Is this because of vectors?

If i can just change the rotation coordinates of the texture tags randomly by 90 degrees I would be happy.

here is my script so far:
-------------------------------------------------------
import c4d
import random
import math
from c4d import gui
#Welcome to the world of Python

def main() :
doc = c4d.documents.GetActiveDocument()

objs = doc.GetActiveObjects(True); #Stores selected objects in vairable 'objs'
mats = doc.GetActiveMaterials(); #Stores selected materials in variable 'mats'
angles = [90,-90,180, 0];
numMats = len(mats) - 1;
numangles = len(angles) - 1;

for _obj in objs:
doc.SetActiveObject(_obj,0);
doc.SetActiveMaterial(mats[random.randint(0,numMats)],0);
c4d.CallCommand(12169); # Apply
tag = _obj.GetTag(5616); #Selects current objects texture tag
doc.SetActiveTag(tag); #Selects the object's texture tag
tag()[c4d.TEXTURETAG_PROJECTION]=3; #Sets projection to Cubic
vec = c4d.Vector(angles[random.randint(0,numangles)], 0, 0); #Here I am changing the X vector only
tag.SetRot(vec);
print vec;

if __name__=='__main__':
main()

-------------------------------------------------------

I will greatly appreciate your help.

Thank you

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 05/06/2012 at 15:42, xxxxxxxx wrote: