ForEachLoop
main mel draw photography about

ForEachLoop

 


 

Align two objects

Mel Scripting January 31st, 2008

Description: This simple script could help you align 2 objects together. I put an option you could turn on if you like the object to be orientated as well. First, select the target object which you want to align to and then shift select the object that will get aligned.

 

 

 

 

 

global proc s_alignObjProc()
{
string $sel[]=`ls -sl`;
int $stateCb =`checkBox -q -v alignObjCB`;
if ($stateCb == 0)
{
delete `pointConstraint $sel[0] $sel[1]`;
} else
{
delete `parentConstraint $sel[0] $sel[1]`;
}
}
//Below is a simple window
if (`window -exists alignObjWindow`)
{
deleteUI alignObjWindow;
}
window -t "Align Objects" alignObjWindow;
rowColumnLayout -numberOfRows 2;
button -w 128 -bgc 0.95 0.75 0.75 -label "Align objects" -c s_alignObjProc;
checkBox -al "center" -label "with orientation" alignObjCB;
setParent..;
showWindow alignObjWindow;

2 Responses to “Align two objects”

  1. chenxiang Says:

    studing it ,I learn more things,especially “delete `pointConstraint $sel[0] $sel[1]`;”,
    thanks

  2. Sin Says:

    You are welcome.

Leave a Reply