Hi,
I'm currently porting a COFFEE script to Python and it seems that accessing/updating tool settings is much more complicated in Python than COFFEE.
I initially tried something like:
active_tool = doc.GetActiveToolData()
active_tool[c4d.MDATA_AXIS_MODE] == 8 # Free Axis Mode
c4d.EventAdd()
But it had no effect. I eventually found my way to this post which led me to a solution like this:
def tool():
"""Retrieves the currently active tool. Doing so allows you to modify tool settings
unlike GetActiveToolData()"""
active_tool_id = doc.GetAction()
if not active_tool_id:
return
active_tool = c4d.plugins.FindPlugin(active_tool_id, c4d.PLUGINTYPE_TOOL)
return active_tool
def main():
"""Switch from Free Mode to Axis mode and vice/versa.
"""
active_tool = tool()
if active_tool is None:
return
active_tool[c4d.MDATA_AXIS_MODE] == 8 # Free Axis Mode
c4d.EventAdd()
Questions / Requests
- QUESTION: Is there a way of knowing when I should change settings with
ActiveToolData()
vs having to find an instance of the tool/plugin itself? - IDEA: Please add a section to the docs on how to update tool settings.
- IDEA: Please add a helper function like
tool()
to the API for accessing the currently active tool, the present method is a bit convoluted for something people will want to do so frequently.
Thank you,
Donovan Keith