Adverti horiz upsell

Python Batch 2.0.0 for Maya (maya script)

Executes a python command for each selected object, or pair of objects

License
$20.00
(qty: 1)

  • Check 16 Future Updates Included
  • Check 16 Highend3d Quality Checked
  • Check 16 Purchase Guarantee
  • Check 16 Support Included

Compatibility

  • 2014, 2013, 2012

Operating Systems

  • Irix
  • Linux
  • Mac
  • Solaris
  • Windows

History

Created:09/20/2013
Last Modified:09/25/2013
File Size: 11.9 KB

Keywords

Workflow, batch

" "
Video has not loaded yet. This video requires Adobe Flash Player, if you're seeing this message something might be wrong with your Adobe Flash Player installation.
  • Reel
  • Reel
  • 09 35 39 94 pybatch screenshot 4
Executes a python command for each selected object, or for each selected pair/triple/.. of objects.

Speed up a lot of repetetive tasks occuring in rigging, complex scene setup.



Installation:

  Make a shelf button out of the code

Usage:

The function of this tool is best explained by a number of examples.

Example #1: Suppose you would like to create several joint constraints at once:
    orientConstraint("ctrlThumb1", "ThumbJoint1")
    orientConstraint("ctrlIndex1", "IndexJoint1")
    orientConstraint("ctrlMiddle1", "MiddleJoint1")
    orientConstraint("ctrlRing1", "RingJoint1")
    orientConstraint("ctrlPinky1", "PinkyJoint1")

To do so, select the objects in this order:
    "ctrlThumb1", "ctrlIndex1", "ctrlMiddle1", "ctrlRing1", "ctrlPinky1",
    "ThumbJoint1", "IndexJoint1", "MiddleJoint1", "RingJoint1", "PinkyJoint1"

and enter this code inside Python Batch:
    orientConstraint("%1", "%2")

Hit the "Preview Script" button to verify if the intended piece of code was produced, finally hit "Execute Script" to run it.
As you see the order of selection is important - do not select the %1's and %2's alternately, but first select all the %1's sequentially, then all the %2's. It works the exact same way when you use more than two placeholders. Select all the %1's, then all the %2's, all the %3's et cetera.

Note you can also use just one placeholder, for example if you want to modify an attribute, or call a function on a number of objects.

In addition to the selection name placeholders %1, %2.. there are also three special placeholders:
    %i    counter of the current iteration of the script
    %t    total number of iterations (usually equals number of selected objects divided by the number of placeholders)
    %p    percentage (0...1) of iterations processed

With these, you could for example gradually change a certain property over a sequence of selected objects:

Example #2: Say you would like to rotate 10 objects gradually, the last object should do a 90 degree rotation around the Y axis.

To do so, select the ten objects in sequence (for example using the outliner), then execute this script inside Python Batch:
    cmds.setAttr("%1.rotationY", %p*90)

And there are more placeholders! Say you want to orient constraint a number of objects to the SAME objects, you can use the %a, %b, ... placeholders. Always select them first. The %a, %b, .. placeholders will not change for each iteration of the script:

Example #3: You would like to orient constrain objects "feather1", "feather2", ... , "feather50" to "masterControllerStart" and
"masterControllerEnd" with weights gradually changing between the two controllers from start to end.

To do so, select objects in this order:
    "masterControllerStart", "masterControllerEnd", "feather1", ... "feather50"

Then run this script
    cmds.orientConstraint("%a", "%1", weight = 1-%p)
    cmds.orientConstraint("%b", "%1", weight = %p)

This concludes this little introduction. Note you can also use the Math.* functions to have a little fun modifying the
positions of some objects :)\

People who favorited this item:

  • Vojtech Lacina
    Vojtech Lacina
  • chen kun
    chen kun
  • Tanapon10
    Tanapon10
  • Michael Matskevich
    Michael Matskevich
  • 7ks3
    7ks3
  • crisosphinx
    crisosphinx
  • Jianye Wang
    Jianye Wang
  • inlet511
    inlet511