Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    How to Rotate an Object

    Cinema 4D SDK
    r25 s24 r23 python macos windows
    2
    7
    1.5k
    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.
    • W
      WDP
      last edited by ferdinand

      How can the formula for the coordinate angle want to change the angle?
      Thanks very much!

      edit: This topic has been forked from python-objekte-x-y-z by @ferdinand

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by

        Hello @WDP,

        thank you for reaching out to us. Please follow the rule of separate topics for separate questions for future questions (unless they are direct follow-up questions). I have forked your question from the original topic.

        About you question. There is our Python Matrix Manual which goes over the basics of constructing transforms for objects. Furthermore, there are some rotation matrix convenience methods in c4d.utils with which an object can be rotated about one of the world frame axes (MatrixRotX, MatrixRotY, MatrixRotZ). The following code from the other thread would for example rotate all objects by 45° on the world Y-axis.

        for obj in selected:
                # Get the global matrix of the object, set its offset and write it back.
                mg = obj.GetMg()
                mg *= c4d.utils.MatrixRotY(c4d.utils.DegToRad(45.))
                obj.SetMg(mg)
        

        Finnaly, you can also access object transforms as parameters, e.g., myObject[c4d.ID_BASEOBJECT_REL_ROTATION] or myObj[c4d.ID_BASEOBJECT_ABS_ROTATION] and we have also a quaternion type with c4d.Quaternion. But these approaches to rotation are only rarely needed, most of the time the global or local matrix of an object retrieved with BaseObject.GetMg() and .GetMl() should be the way to go.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • W
          WDP
          last edited by

          Thank you very much!

          1 Reply Last reply Reply Quote 0
          • W
            WDP
            last edited by

            Hello, I can control the visibility of the objects I know but how can I activate and deactivate the red button?
            Thanks very much!

            1 Reply Last reply Reply Quote 0
            • ferdinandF
              ferdinand
              last edited by

              Hello @WDP,

              please follow the rule of opening new topics for new questions.

              Thank you for your understanding,
              Ferdinand

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 0
              • W
                WDP
                last edited by WDP

                Hello that works with the object rotation, thanks, but how can I only rotate the axes without the object rotating?
                Rotation.jpg

                ferdinandF 1 Reply Last reply Reply Quote 0
                • ferdinandF
                  ferdinand @WDP
                  last edited by

                  Hello @WDP,

                  this question would technically also be a new topic, please follow these rules.

                  There is no formal notion of an object axis in the sense of a moveable entity in the API. Objects have their matrices (the global and the local one), which are effectively their own coordinate system opposed to the world coordinate system (or transform or frame when you prefer these terms over coordinate system).

                  So, when you want to reproduce what is possible in the app, and move, rotate, or scale the axes of an object, without moving the geomtery of the object itself, then you will have to transform the vertices of that object. So, when the object has the world offset (0, 0, 0) and you want to move the axes to (100, 0, 0), you must first set the global object matrix to an offset of (100, 0, 0) and then apply the inverse of a transform that translates by (100, 0, 0) to all its vertices. I would recommend reading the matrix manual I did post in my first answer here.

                  This will however only be possible for editable point objects, e.g., a c4d.PolygonObject. You are showing a generator object, i.e., a c4d.BaseObject with some cached geometry in your screenshot. You cannot move the axes for these objects, neither in the SDK nor in the app itself.

                  We had recently this topic which dealt with moving the axes of a polygon object.

                  Cheers,
                  Ferdinand

                  MAXON SDK Specialist
                  developers.maxon.net

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