View Single Post
# 2 12-10-2014 , 12:18 AM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
This can be done within a single loop block

Since this is a class assignment the following isn't working code but a guide.

I have to note, clearing the selection after we've saved a list of objects to act on is very important since the joint command cannot parent joints to multiple objects, you will get an error.


Code:
	selection[] = list selection;
	clear selection; //simply deselects objects and doesn't clear our array variable
	
	// this integer is for renaming consistency
	intCounter = 0;
	
	for(locator in selection){
	
		// need the world position of locator and the xform command is perfect for that
		xyzCoords[] = xform -worldSpace -query -translation locator;
		
		// start making joints at the given postions
		// using the elements of the xyzCoord array
		joint = joint -position xyzCoords[0] xyzCoords[1] xyzCoords[2];
		rename locator ("myTempName_" + intCounter);
		rename joint ("myOtherTempName_" + intCounter);
		intCounter++;

	}
Command Refs:
xform
joint


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::

Last edited by Gen; 12-10-2014 at 12:21 AM. Reason: Adding command ref links