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

    Center Axis with Python

    Scheduled Pinned Locked Moved PYTHON Development
    1 Posts 0 Posters 288 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 21/06/2015 at 01:13, xxxxxxxx wrote:

      Hello,
      I'm trying to make a xpresso setup, as a beginner in python I have a trouble to set axis to center of an object. (For example by default if we convert a text into an editable spline its align stays as left I want its axis to set center automatically. Because other calculations are being made as it is in center)
      As I understand SetMg should be matrix value but I could not convert my vector data to matrix.
      And of course it should only run for once. (Sorry if these questions are silly, as I said I'm a beginner:)😢
      Here is my code; (I'm using it as python node in xpresso )

      import c4d

      def setAxis(obj) :
          size = obj.GetRad()*2
          pos = obj.GetMp() + obj.GetAbsPos()
          for i, point in enumerate(obj.GetAllPoints()) :
              obj.SetPoint(i, point * pos)
          obj.Message (c4d.MSG_UPDATE)
          obj.SetRelPos(pos) #????
          obj.SetMg(pos) ### ??? Axis should be in center of an object but how???

      def main() :
          global Source
          
          if Source.CheckType(c4d.Opoint) :
              setAxis(Source)
          doc.EndUndo()
          c4d.EventAdd()

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