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
    • Register
    • Login

    Best practise to transfer object characteristics

    PYTHON Development
    0
    4
    748
    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

      On 09/05/2018 at 16:52, xxxxxxxx wrote:

      Hi folks,

      usually there are different ways to perform a task and sometimes I'm unsure which one to prefer.

      E.g. like these two ways to transfer the rotation from one object to another in Python.

      Way 1:

        
      obj_2.SetRelRot(obj_1.GetRelRot())  
      

      Way 2:

        
      obj_2[c4d.ID_BASEOBJECT_REL_ROTATION] = obj_1[c4d.ID_BASEOBJECT_REL_ROTATION]  
      

      The outcome is the same here but is one way better than the other and why (e.g. performance-wise)?

      I'd intuitionally tend to the first method but I'm not absolutely sure if it is really superior to way 2.

      Any hints?

      Kind regards,
      Tom

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

        On 09/05/2018 at 19:10, xxxxxxxx wrote:

        This is covered some on a cineversity wiki page, although it doesn't use the exact examples you have:

        https://www.cineversity.com/wiki/Python%3A_Creating_objects_and_modifying_parameters/

        They don't get into object methods like SetRelRot(), so it'd still be interesting to find out if there's a big difference there.

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

          On 10/05/2018 at 02:53, xxxxxxxx wrote:

          Hi,

          The fastest way is the first with SetRelRot().

          darby linked an interesting page on Cineversity wiki, where there's a nice explanation why using the subscript operator [] is slower.

          In the end, performance isn't so important for most scripters and using [] isn't wrong for object's parameters.

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

            On 10/05/2018 at 06:08, xxxxxxxx wrote:

            Hi Darby and Yannick,

            thank you both of you, also for the wiki link.
            So I had the right feeling indeed. 😉

            Kind regards,
            Tom

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