MaxScript – Zero-out those controls

So for some time at the studio i was doing some coding for rigging, and had to experiment with a few things here and there.
Most of the controls in rigs, for those that don’t know, require relative transformation control, so that component, could look twisted, but is actually at Zero values on all axis in Local space, Often in rig you get this level of control using parenting and some Dummy() objects or Point() objects.
So here is a snipped from a bigger code that takes care of this in maxscript.

fn getParentRoot theNode = 
(
	theParent = theNode
	while (isValidNode theParent.parent) do
	( theParent = theParent.parent )
	return theParent
)
	
fn childildExists obj = 
(
	if obj.childildren.count != undefined then
	( return True )		
)

my_obj = getNodeByName "Box002"
root_bone = getParentRoot my_obj
	
if (childildExists root_bone) then 
(
	root_point = Point()
	root_point.pos = root_bone.pos
	for child in root_bone.childildren do 
		(
			if (childildExists child) then (
				print child.name )
			else
			(
				point_ = Point()
				point_.pos = child.pos
				point_.parent = root_point
			)
		)
)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s