Moka Studio
Centre du parc
Rue Marconi, 19
1920 Martigny
SWITZERLAND
Tel: 0041 27 566 70 17
Mail: dev@mokastudio.tv
[Maya Python] Automatic Actions When a Specific Event Occurs
To automatically execute an action when a specific event occurs use the scriptJob command
Example:
#=========================================================================== # This script automatically scales selected objects #=========================================================================== import pymel as pm # Clear the scene pm.newFile(force=1) # Create some objects in the scene nbSpheres = 10; for i in range(nbSpheres): mySphere = pm.polySphere() mySphere[0].translateX.set(i) # Create the event handler to scale the objects eventHandler = pm.scriptJob(e = ["SelectionChanged","ScaleObject()"]) def ScaleObject(): objs = pm.ls(type = "transform", sl=True) for obj in objs: obj.scaleX.set(0.5) obj.scaleY.set(2) obj.scaleZ.set(0.5)
Best regards,
Benoît
- Login to post comments
