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

    Issue Changing Modeling Axis

    Cinema 4D SDK
    python r20
    2
    3
    1.3k
    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.
    • D
      DavidW
      last edited by r_gigante

      I'm trying to convert a working COFFEE script for changing the modeling axis to Python. Updated tool data is printed to the Console but the Axis parameter is not changing.

      import c4d
      
      def main():
          tool_dat = doc.GetActiveToolData()
          tool_dat[c4d.MDATA_AXIS_MODE] = c4d.MDATA_AXIS_MODE_FREE
          c4d.EventAdd()
      
      if __name__=='__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • Y
        y_puech
        last edited by y_puech

        Hi,

        The script you posted does work with for instance the Live Selection tool but does not work with Move/Scale/Rotate tools.
        The following script changes the MDATA_AXIS_MODE to MDATA_AXIS_MODE_FREE for any active tool:

        import c4d
        from c4d import plugins
        
        def SetToolData(doc, toolID, paramID, data):
            plug = plugins.FindPlugin(toolID, c4d.PLUGINTYPE_TOOL)
            if plug is None:
                return
        
            plug[paramID] = data
        
        def main():
            SetToolData(doc, doc.GetAction(), c4d.MDATA_AXIS_MODE, c4d.MDATA_AXIS_MODE_FREE)
            c4d.EventAdd()
        
        
        if __name__=='__main__':
            main()
        

        The above script does not use GetActiveToolData(). It retrieves the object for the active tool (with FindPlugin()) and sets the parameter (with operator []).
        For some technical reason, several tools need their settings to be changed via parameters and not accessing the tool data container directly.

        Best regards,
        Yannick

        Former MAXON SDK Engineer

        1 Reply Last reply Reply Quote 0
        • D
          DavidW
          last edited by

          Thanks for the solution and explanation Yannick. It's working perfectly now and I can finish converting my scripts.

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