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
    • Recent
    • Tags
    • Users
    • Login

    Get centre of the Text Spline object [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 303 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 23/12/2014 at 15:14, xxxxxxxx wrote:

      Hi guys.

      What would be the best way to get Text Spline (with some text in it) centre point coordinates?

      I am a little bit rusty with Python, please excuse me if it's a simple question.
      Thank you.

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

        On 23/12/2014 at 17:27, xxxxxxxx wrote:

        Hi,

        This code in a Python Expression tag w/ a link field in the UserData works for me:

          
        """Spline Center Expression Tag   
        Moves object to the center of the spline"""   
          
        import c4d   
        #Welcome to the world of Python   
          
        def main() :   
            #Get the spline   
            spline = op[c4d.ID_USERDATA,2]   
            if spline is None:   
                return   
               
            #Retrieve the center of the bounding box   
            spline_center = spline.GetMp()   
               
            #Move object this Expression Tag is on to the center of   
            #the bounding box   
            obj = op.GetObject()   
            obj.SetRelPos(spline_center)   
        

        This is all calculated in Local coordinates, I'm not sure how that would change for Global coordinates.

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

          On 24/12/2014 at 06:25, xxxxxxxx wrote:

          Oh yes, that's right, it's GetMp() I was looking for. Thanks Dinovan, I have to dust off my skils at reading sdk.

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