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

    Modify Axis

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 638 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

      On 30/12/2016 at 20:56, xxxxxxxx wrote:

      Hello there,

      How I can modify the Y Axis to -100% using python as shown in the screenshot below:

      Thanks

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

        On 31/12/2016 at 11:59, xxxxxxxx wrote:

        Hi,

        I found the solution below :

        import c4d  
          
        def main() :      
          world_pos  = op.GetMg().off  
          bBox_pos  = op.GetMp()  
          bBox_size = op.GetRad()  
          local_bottom = c4d.Vector(0,bBox_pos.y - bBox_size.y,0)  
          world_bottom = local_bottom + world_pos  
          
          yPos = c4d.Vector(0,world_bottom.y,0)  
          
          oldm = op.GetMg()  
          points = op.GetAllPoints()  
          pcount = op.GetPointCount()  
            
          op.SetAbsPos(yPos)  
          
          newm = op.GetMg()  
          for p in xrange(pcount) :  
              op.SetPoint(p,~newm*oldm*points[p])      
              op.Message(c4d.MSG_UPDATE)  
          
          c4d.EventAdd()  
          
        if __name__=='__main__':  
          main()
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 01/01/2017 at 08:23, xxxxxxxx wrote:

          Take care of this and using child objects ! Since you modify the original axis and since children use relative position this will affect the position of their.
          A good way is to store gobal position/scale/rotation (or simply get the global matrix of it) change the axis and then reasign those data

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

            On 02/01/2017 at 03:12, xxxxxxxx wrote:

            Hi,

            You can find a nice solution inside this post.

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

              On 02/01/2017 at 11:23, xxxxxxxx wrote:

              Hi,

              At the outset I wanted to find a solution to dropping an object to a floor, so I wanted to modify the y axis and put it at the bottom of my object then I set the y position to zero.

              But I find a new solution and it works with all type of object.

              script :

              import c4d  
                
              def main() :  
                if not op:  
                    return  
                world_pos  = op.GetMg().off  
                bBox_pos  = op.GetMp()  
                bBox_size = op.GetRad()  
                local_bottom = c4d.Vector(0,bBox_pos.y - bBox_size.y,0)  
                world_bottom = local_bottom + world_pos  
                
                op[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Y] += -world_bottom.y  
                c4d.EventAdd()  
              if __name__=='__main__':  
                main()
              

              I don't know if can do that differently, and thank you guys for your replies.

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

                On 07/08/2017 at 01:52, xxxxxxxx wrote:

                Thank you for for the nice code example! But it works incorrectly with scaled objects.Confused

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