Issue Changing Modeling Axis



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

  • Global Moderator

    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



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