Axis position



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

    On 24/03/2012 at 07:16, xxxxxxxx wrote:

    Hi all 

    very simple question, how to change the axis position (using python of course)? 
    i can't find the Axis Modification command or something similar in the documentation, maybe i need to use matrix for that 🤢 ??

    an example 'll be very helpful.
    thanks in advance!



  • 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



  • 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.



  • 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()   
    


  • 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 :)



  • 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.

    # 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



  • 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



  • 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



  • 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.



  • 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



  • 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


Log in to reply