Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Texture Tag Coordinate Rotation Help

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 223 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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;
          
          c4d.EventAdd();
          
      if __name__=='__main__':
          main()

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

      I will greatly appreciate your help.

      Thank you

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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:

        It's most likely because your angles must be set as Radians.

        Cheers
        Lennart

        1 Reply Last reply Reply Quote 0
        • First post
          Last post