@m_magalhaes Yes please, and sorry for the delay :3
Posts made by John_Do
RE: Python, tool attributes and hotkeys
Thank you for your detailed answers and sorry for the delay, I was on holiday.
Sorry for the misunderstanding, in my mind hotkeys = shortcuts, I didn't want to make any particular distinction. What you described is also called Sticky Keys in some softwares.
To answer your questions : I want to be able to modify tool settings / attributes while the tool is enabled AND in interactive mode. Since I don't want to bother with gazillions of shortcuts and multiple keyboards, it has to be context sensitive so I can use the same set of keys with many tools.
But a picture is worth a thousand words, so I made a little demo of what I want to achieve in C4D : Modal Bevel Shortcuts demo
As you can see, the shortcuts allows to modify tool settings in real time, without loosing the ability to enter values manually in the attributes fields. What you don't see is that I can use the same set of keys with many tools and in the same fashion ( one key to toggle an option, two other to add / sub values like segments, number of clones etc. ). This software is context-sensitive by design at many levels and allow this kind of customisation without scripting.
Thank you very much for the detailed answer and the script example. I have to take a deeper look at it but it works, and I've made two other scripts from it to simulate what I show in the link above. Please take a look : Cinema 4D - Modal Bevel Shortcuts POC #1
As you can see
- the part with the shortcuts works : I can press keys and alter active tool settings as expected.
- but the tool is no longer interactive, so when I want to alter the bevel radius, it doesn't work. I have to undo and restart the bevel.
So these results are encouraging but there is room for improvements :
- Is there is a way to alter the current tool settings values without loosing the tool interactivity ? An access to some kind of "tool buffer" ?
- Let's say I want to add function for others tools in the same way. Wouldn't the script become too slow at some point if there is many if c4d.IsCommandChecked() commands ?
- Is there is a way to gather all the commands in one file / script but output as many commands as shortcuts needed ? Right now I have one script per command, it's a bit clunky.
I guess plugin and command registering is the answer ?
Python, tool attributes and hotkeys
Python beginner here, my goal is to write a script or a plugin to interact with some (active) tool attributes through a predefined set of hotkeys. In short, context-sensitive hotkeys. As a bonus goal, I would like to add some settings in the Preferences window to change the hotkeys.
Until now I've managed to write simple python scripts ( but you can call it macros ), like these lines to change bevel mode f.e. :
if c4d.IsCommandChecked(431000015) is True : if tool()[c4d.MDATA_BEVEL_MASTER_MODE] == 0: tool()[c4d.MDATA_BEVEL_MASTER_MODE] = 1 else: tool()[c4d.MDATA_BEVEL_MASTER_MODE] = 0 c4d.EventAdd()
It kind of works but it doesn't affect the active tool, only the UI.
And that's all for the moment. The SDK isn't really useful since I don't know where to start and how implement this, plus I guess there may be some specific constraints due to the interactive part.
So I would like to get some clues on the best way to tackle this. I've watch many C4D Python tutorials, look through the docs, the Python SDK and read few scripts but it doesn't make sense yet. Like baseContainer, what is this thing and why I have to call it to interact with a tool ? ( I'm really a beginner )
From what I've read what I want to do is not possible with a simple script, I should rather write a plugin to have the code running in background to evaluate tool activation and keystrokes. Is that correct ? Is it why the script doesn't trigger the active tool ?