Jump to content

Sign in to follow this  
Hexbob

Keyboard Shortcuts within a Script

Recommended Posts

Hi there! I am new to Cinema, having come from a different 3D package, and have been playing around with the Python API to create various scripts replicating certain functionality in my original software. These scripts have been very simple, typically calling/toggling commands (with 'c4d.CallCommand(id)', for example), and I have been binding them to different keyboard shortcuts using the 'Customise Commands' Manager.

 

My issue is that I'm creating a large number of small '.py' script files and assigning them manually to shortcuts, and feel that it would be much more manageable and efficient for me to merge my scripts into one main file and assign shortcuts from within it. As a result, I was wondering if there is an easy way of triggering these individual script commands within the main script file as a result of user-inputted keypresses?

 

For example, the type of thing I'm looking to achieve is:

if user_presses_F10_key:
  c4d.CallCommand(12083) # Change to 'Top' view
  
elif user_presses_CTRL+TAB_keys:
  c4d.CallCommand(12080) # Change to 'Right' view

Any help/detailed answer would be really appreciated as I'm still fairly new to Python in general too!

Thanks!

Share this post


Link to post
Share on other sites

I know next to nothing of python, but in the Customize Commands there is a section for Plugin where the Command, Tool, Object, Scripts, etc. can be filed into a certain plugin.  This means it could have it's own unique keyboard shortcut only when it's within that particular plugin separate from all the other keyboard shortcuts for c4d.  If true you could call your main script a plugin with a name like like "Hexbob's stuff".  Now assign the scripts as part of that "plugin" and give them their keyboard shortcuts.  As far as programming this in python I have no idea.

Share this post


Link to post
Share on other sites

I think you could create as many as "single line callcommand" scripts and asign them shortcuts as you want. This way if you press F10, it change your view to top etc...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...