View Full Version : Python - Texture Tag Coordinate Rotation Help!

06 June 2012, 06:12 PM
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:
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
print vec;


if __name__=='__main__':


I will greatly appreciate your help.

Thank you


CGTalk Moderation
06 June 2012, 06:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.