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

    Axis position

    PYTHON Development
    0
    11
    1.9k
    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
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 24/03/2012 at 10:33, xxxxxxxx wrote:

      axis are just a representation of the difference of local and global coordinates. and yes you will have
      to use matrices 🙂

      edit :

      here is the main entry point to mess with local/global coordinates.

      http://www.thirdpartyplugins.com/python/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseObject/index.html#c4d.BaseObject

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 24/03/2012 at 11:18, xxxxxxxx wrote:

        thank you littledevil for your answer 🙂
        i know that axis are just a representation. to get this, i use usually

          
        obj.GetMg().off  
        

        the problem is, if i change these coordinates, the object will move too, and i need to keep the object in the same postion.

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 24/03/2012 at 14:00, xxxxxxxx wrote:

          You can only move the axis for point object.
          You first store the original points, move the object, then reset the points
          to the original positions.
          This command example moves the axis to the parent.

          Cheers
          Lennart

            
          # MoveAxisOnly tcastudios©2012   
          # Move the axis of a point object and keep points at original local(parent) position   
            
          import c4d   
          from c4d import Vector as v   
            
          def main() :   
              if op is None or not op.CheckType(c4d.Opoint) : return False   
              oldm   = op.GetMg()   
              points = op.GetAllPoints()   
              pcount = op.GetPointCount()   
            
              doc.StartUndo()   
              doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)   
              op.SetAbsRot(v(0))   
              op.SetAbsPos(v(0))   
              op.Message(c4d.MSG_UPDATE)   
            
              newm    = op.GetMg()   
            
              for p in xrange(pcount) :   
                  op.SetPoint(p,~newm*oldm*points[p])   
            
              op.Message(c4d.MSG_UPDATE)   
              c4d.EventAdd()   
              doc.EndUndo()   
            
          if __name__=='__main__':   
              main()   
          
          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 25/03/2012 at 06:52, xxxxxxxx wrote:

            i got the idea, thank you very much Lennart 🙂

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 27/03/2012 at 07:25, xxxxxxxx wrote:

              This one demonstrates a little other approach and is about 2 lines shorter than Lennarts version. Tongue

              # coding:      ascii  
              # file:        <scriptmanager>  
              # description: Reset an object's position to the origin while its points keep  
              #              their position globally.  
                
              import c4d  
                
              def main() :  
                if not op or not op.CheckType(c4d.Opoint) :  
                    return  
                
                mg     = op.GetMg()  
                pcount = op.GetPointCount()  
                
                # tell c4d to encapsulate the following steps into a single  
                # undo step  
                doc.StartUndo()  
                
                for i in xrange(pcount) :  
                    point = op.GetPoint(i)  
                    doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)  
                    op.SetPoint(i, point * mg)  
                
                doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)  
                op.SetAbsPos(c4d.Vector(0))  
                op.SetAbsRot(c4d.Vector(0))  
                op.Message(c4d.MSG_UPDATE)  
                
                # close the undo encapsulation and tell c4d to update the gui  
                doc.EndUndo()  
                c4d.EventAdd()  
                
              main()
              

              Cheers!
              -Niklas

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 27/03/2012 at 09:10, xxxxxxxx wrote:

                Hi Niklas, put a timer in them and explore:)

                Cheers
                Lennart

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 24/10/2012 at 08:01, xxxxxxxx wrote:

                  Hello ,

                  I tried to change your script to set the axis to the center of the bounding box with

                  #newm    = op.GetMg()   
                  newm    = op.GetMp()
                  

                  but i get a float instead of vector error?

                  Traceback (most recent call last) :
                  File "'scriptmanager'", line 32, in <module>
                  File "'scriptmanager'", line 25, in main
                  TypeError: argument 2 must be c4d.Vector, not float

                  any ideas ?

                  kind regards mogh

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

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 24/10/2012 at 11:21, xxxxxxxx wrote:

                    Possibly because GetMg() does not return a matrix, but a *Vector*.
                    Didn't check it, however.

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

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 25/10/2012 at 00:21, xxxxxxxx wrote:

                      but

                      opt.SetMg(newm)
                      

                      says it wants a vector ?

                      argument 2 must be c4d.Vector, not float

                      anyway how do i get a matrix from a single vector remaining the orientation.

                      I am sorry, math is not my profession ...

                      kind regards

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

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 29/10/2012 at 01:52, xxxxxxxx wrote:

                        Code Vonc
                        has some interesting stuff - still getting nowhere

                        http://code.vonc.fr/?a=22

                        kind regards

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