(Deprecated)

vcCommandEvent

vcCommandEvent contains information about mouse and/or keyboard events related to the execution of commands. For example, an instance of vcCommandEvent is an argument passed to the OnInteractive event handler.

Properties

Name Type Access Description
EyeToMouse vcVector R Gets offset (in World coordinates) from the camera eye point to the pointer on view plane.
Key Integer R Gets either the Windows scan code for a pressed key or an offset value for a mouse wheel movement in which a negative value indicates a downward rotation of a mouse wheel.
MouseOnFloor vcVector R Gets the position of the mouse on the layout floor (ex: Z == 0) in World coordinates.
MouseOnViewPlane vcVector R Gets the position of the pointer on the view plane in World coordinates.
ShiftState Enumeration R Gets the bit mask indicating which mouse buttons or modifier keys are pressed by a user. There are also bits for single and double click detection.

See Command Event Constants more for information.

Type Enumeration R Gets the command event type.

See Command Event Constants more for information.

X Integer R Gets the X-axis coordinate of pointer in the 3D window.
Y Integer R Gets the Y-axis coordinate of pointer in the 3D window.

Examples

Example. Create a keydown event for a command

from vcApplication import * 

# Copy the following code in a python command __init__.py file 


def OnStart(): 
  cmduri = getApplicationPath() + 'CommandEvent.py' 
  cmd = loadCommand("CommandEvent",cmduri) 
  addMenuItem(VC_MENU_ADDONS,"Command Event", -1, cmd) 


# And copy the following code in a CommandEvent.py file.
# Place both files in a folder, and then store the folder in My Commands folder 


from vcCommand import * 

cmd = getCommand() 

def endState(): 
  print "Command event deactivated" 

def setState(): 
  cmd.ExecutionType = VC_COMMAND_TOOL 
  cmd.setEventState(event_handler) 

def event_handler(arg): 
  print "Mouse cursor cordinates on 3DWorld" 
  print " X: ", str(arg.X), " Y:", str(arg.Y) 
  print "*"*100 
  if arg.Type == VC_EVENT_MOUSE_DOWN:    
    print "Mouse Down at" 
    vec = arg.MouseOnFloor 
    print "X:", str(vec.X), " Y:", str(vec.Y), " Z:", str(vec.Z) 
    print "*"*100 

  if arg.ShiftState == VC_SHIFTSTATE_CTRL: 
    cmd.setNextState(endState) 

addState(setState)