View Full Version : Need a tips on Mesh Instancing Mel Script
12-04-2006, 03:39 PM
Imagine I can select a bunch of object and select last another mesh:
I want to query " all the position of my selection - 1 " ( not the last one ) and Copy as instance of the last object at that different location in order to create Instanced object whenever I've fogot to check my duplicate options ^^ and find that I've copy 100 object in simple copy ( not instance ) :cry: .
Can you help me ^^ ?
12-04-2006, 05:44 PM
string $selObjs = `ls -sl` ; // all of the selected
int $count = `size($selObjs)` ; // how many selected?
int $second2last = $count-1 ;
string $dup = $selObjs[$second2last] ; // last selected
float $pos , $rot ;
int $i ;
string $instanz ;
string $tmp ;
// for every item in the selection list DO:
for ( $i = 0 ; $i < $second2last ; $i++ )
clear $pos ; clear $rot ; // make sure no old values are still stored here
$tmp = `duplicate -ilf $dup` ; // duplicate the last object 1 time
$instanz = $tmp ; // trick; duplicate returns an array, but we only need the very 1st one
$pos = `xform -q -ws -t $selObjs[$i]` ; // get the position of the item to clone
$rot = `xform -q -ws -ro $selObjs[$i]` ; // get the rotation as well
xform -ws -t $pos $pos $pos $instanz ; // set the instance to that position
xform -ws -ro $rot $rot $rot $instanz ; // set the rotation as well
delete $selObjs[$i] ; // delete the 'wrong' object
12-05-2006, 08:22 AM
Thanks a Lot Brubin =^)
That a great and Usefull Script. Autodesk need to implement that type of script in the next release of maya ^^
Maybe someone should wants to delete after all the "Target Copy" to kepp just the "Instance Object result". May Add some line in the Mel Script.
And The Rotation Information arent preserved with that script. The translate information are preserved
Very good Explaination about the different Line command.
If I've understood well "HTH" may significate "Hope This Help"
12-05-2006, 11:42 AM
12-05-2006, 04:09 PM
thanks for this little fix Brubin. Now It's perfect ^^
12-05-2006, 04:09 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.