Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search

Texture Tag Coordinate Rotation Help

  Topic Search Topic Search
Anand View Drop Down

Joined: 2011 Dec 28
Online Status: Offline
Posts: 2
Direct Link To This Post Topic: Texture Tag Coordinate Rotation Help
    Posted: 2012 Jun 05 at 10:50am
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

Back to Top
tcastudios View Drop Down

Joined: 2005 Jan 21
Location: Sweden
Online Status: Offline
Posts: 559
Direct Link To This Post Posted: 2012 Jun 05 at 3:42pm
It's most likely because your angles must be set as Radians.

Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.