"""
HB_Move V1.0

Last Modified: 6/25/2015
Works with CINEMA 4D R16.050 and up.
Copyright: Holger Biebrach, www.c4dstuff.com

Name-US: HB_Move
Description-US: Move Tool [SHIFT-CLICK: Enable Quantize Snapping]

This Script does following things:
- Enables the Movetool
- Show Axis if hidden
- Disable Quantize Snapping if enabled 

- Shift-Click: Enable Quantize Snapping and set it to 100 Units

Video Tutorial:
https://youtu.be/eEcAttV56kE?t=21m

Name-DE: HB_Move
Description-DE: Move Tool [SHIFT-CLICK: Aktiviere Quantize Snapping]

ChangeLog:
6/11/2015 Release Version

"""

import c4d, math
from c4d.modules import snap
from c4d import documents, plugins

def tool():
    return c4d.plugins.GetToolData(doc, doc.GetAction())




def main():
    
    bc = c4d.BaseContainer()
    if c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD,c4d.BFM_INPUT_CHANNEL,bc):
        
        if bc[c4d.BFM_INPUT_QUALIFIER] ==0 : # NO MODIFIER
            c4d.CallCommand(200000088) # Move
                        
            tool()[c4d.MDATA_AXIS_ROT]=0 #AXIS mode
            tool()[c4d.MDATA_AXIS_NORMAL_PSR]=False
            
            if (snap.IsQuantizeEnabled(doc)):

                c4d.CallCommand(c4d.QUANTIZE_ENABLED)

            snap.SetQuantizeStep(doc, None, c4d.QUANTIZE_MOVE,10)
            if not (c4d.IsCommandChecked(1016176)):
                c4d.CallCommand(1016176) # Show Axis
                
        if bc[c4d.BFM_INPUT_QUALIFIER] ==1 : # SHIFT
            c4d.CallCommand(200000088) # Move
            if not (snap.IsQuantizeEnabled(doc)):
                # Enable quantizing if not activated
                c4d.CallCommand(c4d.QUANTIZE_ENABLED)
                
            snap.SetQuantizeStep(doc, None, c4d.QUANTIZE_MOVE,100)
                        
            if not (c4d.IsCommandChecked(1016176)):
                c4d.CallCommand(1016176) # Show Axis
        
        
        if bc[c4d.BFM_INPUT_QUALIFIER] ==2 : # CTRL
            
            c4d.CallCommand(200000088) # Move
            
            tool()[c4d.MDATA_AXIS_ROT]=5 #Normal mode
            tool()[c4d.MDATA_AXIS_NORMAL_PSR]=True
            
            if (snap.IsQuantizeEnabled(doc)):

                c4d.CallCommand(c4d.QUANTIZE_ENABLED)

            snap.SetQuantizeStep(doc, None, c4d.QUANTIZE_MOVE,10)
            if not (c4d.IsCommandChecked(1016176)):
                c4d.CallCommand(1016176) # Show Axis
        
        

if __name__=='__main__':
    main()
    c4d.EventAdd()
